【问题标题】:How do I redirect domains to different ports on the same server?如何将域重定向到同一服务器上的不同端口?
【发布时间】:2020-01-20 16:59:16
【问题描述】:

我想在一台 Ubuntu 服务器上使用不同的软件,并通过不同的域和相同的 (80) 端口访问它们。该软件在本地的不同端口中运行。例如:

Soft1:example.com:80 -> localhost:9000

Soft2: deneme.com:80 -> localhost:6555

我能做什么?谢谢。

【问题讨论】:

    标签: ubuntu dns port portforwarding


    【解决方案1】:

    您可以通过在 Web 服务器上设置虚拟主机/服务器来实现此目的。既然你没有提到任何网络服务器,我将使用 NGINX。

    所以继续关注this guide to setup NGINX。对于您的情况,您将在 /etc/nginx/sites-enabled/ 中为您的域 example.comdeneme.com 创建两个配置文件,配置如下:

    /etc/nginx/sites-enabled/example.com:

    server {
        listen       80;
        listen       [::]:80
        server_name  example.com
    
        location / {
               proxy_pass http://localhost:9000/;
        }
    }
    

    /etc/nginx/sites-enabled/deneme.com:

    server {
        listen       80;
        listen       [::]:80
        server_name  deneme.com
    
        location / {
               proxy_pass http://localhost:6555/;
        }
    }
    

    现在将您的域指向您的服务器 IP,您应该会看到您的应用程序。

    【讨论】:

    • 很高兴为您提供帮助:)
    猜你喜欢
    • 2015-03-15
    • 1970-01-01
    • 2014-08-05
    • 2015-05-29
    • 2016-10-06
    • 2010-10-10
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多