douzhuang6321 2017-06-28 14:50
浏览 74
已采纳

如何对在同一服务器上运行的不同进程使用不同的域名

Assume I have three different sites running. Node.js app on port 3000, Apache/PHP on port 80, and then a Go app on port 5000.

How can I have three different domain names that go to each port?

I was thinking of a basic route system on port 80 that all domains refer to, then the program looks at url and redirects to correct port. Is that recommended? Is there a better way?

Thanks

  • 写回答

2条回答 默认 最新

  • doukenqiong0588 2017-06-28 14:59
    关注

    If you're already using Nginx, you can very easily set up named-based reverse proxy vhosts for the apps that aren't on port 80:

    server {
        listen *:80;
        server_name nodeapp.mydomain.com;
        location / {
            proxy_pass http://localhost:3000;
        }
    }
    
    server {
        listen *:80;
        server_name goapp.mydomain.com;
        location / {
            proxy_pass http://localhost:5000;
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏