我使用nginx与多个位置来指导请求到我的网站和我的api。 我使用certbot来生成SSL证书,并自动添加行到nginxconfiguration来configurationSSL。
这些文件是从html文件夹中提供的,没有任何问题,但是,任何对“redacted.org/api”的Web请求都会返回502 Bad Gateway。 就好像SSL未configuration为“/ api”位置,而是针对“/”位置。 我需要在我的configuration(下面)中更改这个工作?
server { listen 80; server_name redacted.org www.redacted.org; location /api { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location / { root /var/www/html; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/redacted.org/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/redacted.org/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot if ($scheme != "https") { return 301 https://$host$request_uri; } # managed by Certbot }
运行在数字海洋Ubuntu 16.04.2框中
从评论移动
上游有问题。 错误502显示何时上游停机。 所以需要检查上游并修复它。