我已将 nginx 设置为某些后端服务的反向代理,如下所示:
http {
server {
listen 80;
location /service-1/ {
proxy_pass http://127.0.0.1:8081/;
proxy_http_version 1.1;
proxy_redirect off;
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-Host $server_name;
}
location /service-2/ {
proxy_pass http://127.0.0.1:8082/;
proxy_http_version 1.1;
proxy_redirect off;
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-Host $server_name;
}
}
}
每个后端服务都有autoindex on;
,因此导航到每个后端服务(http://localhost/service-1/,http://localhost/service-2/,...)让我快速概览一下它们所暴露的内容。
有没有办法为反向代理本身生成自动索引?
我想导航至http://本地主机/获取已配置位置的列表。