我试图将https://mydomain.assuscomm.com/proxmox/重定向到安装了proxmox虚拟机管理程序的内部IP和端口。
但是,只有在location指令为“ /”时,我才能使它起作用。如果使用相同的配置,但是将位置URI更改为“ / proxmox /”或任何其他不是root的URI,那么我得到的只是空白页。似乎对uri的位置匹配成功了,但是重定向有些失败了。
日志表明重定向后对proxmox的“ GET”请求失败。如果我的位置URI设置为“ /”,则不会发生这种情况。
2019/03/25 14:06:58 [错误] 7693#7693:* 2341 open() “ /etc/nginx/html/pve2/js/pvemanagerlib.js”失败(2:无此类文件或 目录),客户端:192.168.1.1,服务器:mydomain.asuscomm.com, 请求:“ GET /pve2/js/pvemanagerlib.js?ver=5.3-8 HTTP / 1.1”,主机: “ mydomain.asuscomm.com”,引荐来源网址: “ https://mydomain.asuscomm.com/proxmox/”
以下配置失败:
server {
server_name mydomain.asuscomm.com;
auth_basic "Administrators Area";
auth_basic_user_file /etc/nginx/.htpasswd;
location /proxmox/ {
proxy_pass https://192.168.1.121:8006/;
proxy_redirect default;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mydomain.asuscomm.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain.asuscomm.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
}
server {
if ($host = mydomain.asuscomm.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name mydomain.asuscomm.com;
listen 80;
return 404; # managed by Certbot
}
但是,如果我将位置匹配项更改为“ /”(见下文),则一切正常,并且我已成功重定向到proxmox登录页面。
我在做什么错了?
location / {
proxy_pass https://192.168.1.121:8006/;
proxy_redirect default;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}