NGINX:同一域但端口不同的多个代理传递

时间:2019-02-25 05:20:16

标签: node.js ssl nginx networking localhost

这里是情况:

我最多有500个独立的localhost应用程序,它们都在一台服务器上同时运行。我的路由器打开了80、443、8000至8500端口。我的客户端可以连接到他们选择的每个不同的localhost应用程序。我的任务是找出使用1个域的方法:example.com

如果我可以使用查询字符串告诉NGINX重定向到哪个应用程序,那就太好了。例如,如果exam​​ple.com是我的域名,并且我打开了端口443以连接到它,那么我可以执行以下操作会很好:

https://example.com?port=8300

然后NGINX会将请求重定向到localhost:8300

如果无法完成,则另一个解决方案是请求: https://example.com:8300

然后NGINX会将请求重定向到localhost:8300

我当前的设置在端口443上有https://example.com重定向到localhost:8080(NGINX配置代码:)

  

服务器{

IF(an...
     

Certbot       ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; #管理者   Certbot       包括/etc/letsencrypt/options-ssl-nginx.conf; #由Certbot管理       ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; #由Certbot管理

     

}服务器{       如果($ host = example.com){           返回301 https:// $ host $ request_uri;       }#由Certbot管理

    server_name example.com;

    location / {
            proxy_pass http://localhost:8080/;
    }

listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by
     

}

但是我需要一定范围的proxy_pass参数,并且它们需要与查询字符串或域名的端口相对应。

我没有找到有关此操作的文档或在线文章。谢谢!

0 个答案:

没有答案
相关问题