如何解决如何使用侍应生为烧瓶应用程序正确配置NGNIX for SSL
我有一个简单的烧瓶应用程序,正在使用侍应生/ nginx服务/托管
这些规则可以与SSL一起正常工作
server {
listen 443 ssl;
listen [::]:443 ssl;
include snippets/number2.conf;
include snippets/ssl-params.conf;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name https://exanple.com;
location / {
proxy_pass http://example.com:5000/;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
listen [::]:80;
server_name domain;
return 302 https://$server_name$request_uri;
}
但是,这些服务与女服务员/ nginx的应用程序无法正常工作。请注意,该服务器还在端口8069上运行另一个应用程序。
server {
listen 443 ssl;
listen [::]:443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
root /var/www/html;
server_name ip.adress;
rewrite ^/$ https://ip.adress;
location / {
proxy_pass http://ip.adress:8069;
}
}
server {
listen 80;
listen [::]:80;
server_name ip.adress;
return 301 https://ip.adress$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
include snippets/number2.conf;
include snippets/ssl-params.conf;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name https:/example.com;
location / {
proxy_pass http://example.com:5000/;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
listen [::]:80;
server_name domain.com;
return 302 https://$server_name$request_uri;
}
尝试过多种服务器规则组合,但此时我迷路了。
解决方法
下面的proxy_pass http://ip.adress:5000;
是location /
中的主要重要行,以使所有内容正常工作吗?
我能够弄清楚。对于其他遇到麻烦的人,我不得不使用反向代理。我listened to port 8001
和used a proxy port 5000
和header of Host $host
。我还向烧瓶应用添加了url_scheme='https'
。
https://docs.pylonsproject.org/projects/waitress/en/stable/reverse-proxy.html
server {
listen ip.adress:8001 ssl;
include snippets/ssl-self.conf;
include snippets/ssl-params.conf;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name ip.adress;
location / {
proxy_pass http://ip.adress:5000;
proxy_set_header Host $host;
}
}