小编baz*_*ire的帖子

nginx 在两个不同的端口上接受 HTTP 和 HTTPS 请求

我有一个 nginx 服务器设置(两个配置文件),其中有两个 gunicorn Web 服务器设置和运行。一个 gunicorn 是生产,另一个是登台。

我希望 nginx 向 xyz.com 提供 http 请求以及向 xyz.com 提供 https 请求到生产 gunicorn 服务器 @ 127.0.0.1:8000。

我已经完成了这个:

server {
   listen 80;
   server_name xyz.com;
   return 301 https://$http_host$request_uri;
}

server {
   listen 443 ssl;
   server xyz.com;
   ..... <<< ssl stuff
  location /{
      .... proxy_stuff
      proxy_pass http://127.0.0.1:8000;
  }
}
Run Code Online (Sandbox Code Playgroud)

我还希望到 xyz.com:8080 的 http 流量和到 xyz.com:8080 的 https 流量到达临时服务器 @ 127.0.0.1:8081。我已经能够获得 https 流量到 xyz.com:8080 工作如下:

server {
   listen 8080 ssl;
   server_name xyz.com;
   ...... << ssl stuff
   location …
Run Code Online (Sandbox Code Playgroud)

nginx https

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

https ×1

nginx ×1