当我配置 nginx 重定向/monitor
到 opensearch 时,opensearch 接收请求并将用户重定向到/app/something
不在的目录/monitor
,从而失败(错误 404)。
我的 nginx 配置是
upstream opensearch {
server 172.20.0.3:5601;
}
server {
listen 443 ssl;
server_name maindomain;
server_tokens off;
#access_log off;
error_log /var/log/nginx/cii.error_log debug;
access_log /var/log/nginx/cii.error_log;
ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;
include /var/ssl/options-ssl-nginx.conf;
ssl_dhparam /var/ssl/dhparam.pem;
location ~ ^/monitor(/?)(.*) {
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_pass_header User-Agent;
proxy_pass http://opensearch/$2;
}
#put the / location AT THE END
location / {
root /usr/share/nginx/html;
}
}
有什么想法我可以如何配置 nginx(或 Opensearch?)以继续使用/monitor/app/something
?