我有一个密钥,证书和链证书。 该域看起来像automation.mydomain.comNGINX配置代理到Sinatra服务器的SSL请求
我有一个Sinatra服务器上运行localhost:3000
,通过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打开。