【发布时间】:2017-04-19 22:41:22
【问题描述】:
有很多关于使用 ngix 作为反向代理的资料,它作为我需要使用的奇怪 Web 服务器应用程序的基本代理对我来说效果很好。我什至有重定向,所以 http 被重定向到 https。
server {
listen 80;
server_name <my server>;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name <my server>;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000";
ssl on;
ssl_certificate cert1.crt.pem;
ssl_certificate_key cert1.key.pem;
ssl_session_cache shared:SSL:10m;
location / {
proxy_pass http://localhost:81; # my existing apache instance
proxy_set_header Host $host;
}
现在我有一个新的皱纹。我想选择一条特定的路径,而不是将其转发到主服务器应用程序。我需要这样做以添加一些 Let's Encrypt 质询响应。每当传入的 url 是 http:///.well-known/acme-challenge/ 时,我想使用静态 nginx 路径而不是转发到主服务器。
有什么想法吗?我尝试在位置目录中添加,但没有奏效。
server {
listen 80;
server_name video.maritimeopscorp.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name video.maritimeopscorp.com;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000";
ssl on;
ssl_certificate cert1.crt.pem;
ssl_certificate_key cert1.key.pem;
ssl_session_cache shared:SSL:10m;
location ~ /.well-known {
<I've tried lots of combinations here.>
}
location / {
proxy_pass http://localhost:81; # my existing apache instance
proxy_set_header Host $host;
}
我也更愿意把它放到 80 块而不是 443 块,但要先小步。
有什么想法吗?
【问题讨论】:
-
对
/.well-known/acme-challenge的 ACME 质询请求通过普通 HTTP 在端口 80 上完成,而不是通过端口 443 上的 HTTPS。 -
这是我关于进入 80 街区而不是 443 街区的最后一点,但我还不能让它在任何一个下工作。
-
你想实现什么,用 certbot 验证服务器并将 SSL 证书存储在本地?
标签: nginx lets-encrypt