【发布时间】:2023-04-02 03:50:02
【问题描述】:
我有密钥、证书和链式证书。 域看起来像automation.mydomain.com
我有一个在 localhost:3000 上运行的 Sinatra 服务器,通过 curl localhost:3000/test 确认。
我想将端口 80 和端口 443 的流量重定向到 3000。这是我的 /etc/sites-enabled/sinatra 配置:
upstream app_aggregator {
server 127.0.0.1:3000;
keepalive 8;
}
# the nginx server instance
server {
listen 0.0.0.0:80;
server_name automation.mydomain.com my_site;
access_log /var/log/nginx/aggregator.log;
# pass the request to the node.js server with the correct headers
# and much more can be added, see nginx config options
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_aggregator/;
proxy_redirect off;
}
}
请注意,上述方法不起作用(http://automation.mydomain.com/ 导致 ERR_NAME_NOT_RESOLVED)。我不确定如何将密钥、普通证书和链证书添加到这个组合中。
我过去使用 node.js 配置解决了这个问题,该配置愉快地使用了密钥并且 SSL 工作得很好,但我从未使用过 nginx。
值得注意的是,我使用的是 Amazon AWS,只打开了 80 和 443。
【问题讨论】:
标签: ubuntu amazon-web-services nginx ssl-certificate reverse-proxy