我在用nginx重写URL时遇到问题。 问题在于URL是否包含domain / .well-known / acme-challenge /,应将其替换为domain / folder / .well-known / acme-challenge。 我该如何重写nginx,使其指向正确的位置。
对nginx配置的请求与此URL一起使用: 域/文件夹/。众所周知/ acme挑战 但是我希望它在发现类似内容时重定向 域/。众所周知/ acme挑战/
这是我的nginx conf:-
#upstream jboss {
# server domain:8080;
#}
server {
listen ip:80;
server_name domain;
access_log /var/log/nginx/domian_access.log;
error_log /var/log/nginx/domain_error.log warn;
# location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
# expires 365d;
#}
location /folder/ {
# ModSecurityEnabled on;
# ModSecurityConfig modsecurity.conf;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
proxy_pass http://ip:8080/folder/;
proxy_connect_timeout 6000;
proxy_send_timeout 6000;
proxy_read_timeout 6000;
send_timeout 6000;
index Main.jsp index.html;
}
#index index.html ;
# try_files $uri $uri/ =404;
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
答案 0 :(得分:0)
我认为您不需要重写URL,而是将URL发送到正确的文件夹。 众所周知,.well-known / acme-challenge是对自动生成的ssl证书的挑战(让加密),因此只需将别名设置为您的机器人编写“挑战”的文件夹,就可以了。
location /.well-known/acme-challenge {
auth_basic off;
alias /directory/to/challenge;
default_type text/plain;
}
这样,它将“接受”并正确应对挑战
即使您一直想重写它,也可以将redirec设置为domain / folder / $ request_uri行:
location /.well-known/acme-challenge {
return 301 http://$host/folder/$request_uri;
}