我有一个安装了nginx并配置为反向代理的ubuntu 18.0.4 lts框:
/etc/nginx/sites-enabled/default
:
server {
server_name example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://0.0.0.0:3000;
}
我有一个在Docker容器中运行且侦听端口3000的网站。使用此配置,如果我浏览到http://example.com,我将看到该网站。
然后,我使用他们网站上的标准安装程序安装了LetsEncypt,然后运行sudo certbot --nginx
并按照说明为mydomain.com启用https。
现在我的etc/nginx/sites-enabled/default
看起来像这样,我无法在https://example.com和http://example.com上都加载网站:
server {
server_name example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://0.0.0.0:3000;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
有什么想法吗?
答案 0 :(得分:1)
我知道了。问题不在于我的nginx / letsencrypt配置,而是提供商级别的网络问题(天蓝色)。
我注意到Network Security Group仅允许端口80上的流量。解决方案是为443添加规则。
添加此规则后,现在一切都会按预期进行。