在Nginx中配置HTTP 302重定向
我在服务器上部署了一个(春季启动)应用程序。可以在http:// vm-name:8081/api/swagger-ui.html上访问。此URL将用HTTP状态302重定向到具有固定查询参数的另一页。它的链接是http:// vm-name:8081/api/swagger-ui/index.html?configurl =/api/docs/swagger-config。
如何在nginx中配置它?我想通过NGINX公开此应用程序。
我尝试添加以下配置,但它给出了“ Whitelabel错误页面。此应用程序没有明确的映射 /错误,因此您将其视为后备。除了
proxy_pass以外,我还需要添加其他指令吗?
谢谢
location /api {
proxy_pass http://vm-name:8081;
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 https;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header Access-Control-Allow-Origin '*';
proxy_max_temp_file_size 0;
proxy_connect_timeout 150;
proxy_send_timeout 100;
proxy_read_timeout 100;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
I have an (spring boot swagger) application deployed on a server. It is accessible on http://vm-name:8081/api/swagger-ui.html. This url gets redirected with http status 302 to another page that has a fixed query parameter. The link for it is http://vm-name:8081/api/swagger-ui/index.html?configUrl=/api/docs/swagger-config.
How do I configure it in nginx? I want to expose this application through nginx.
I tried adding the below config but it gives "Whitelabel Error Page. This application has no explicit mapping for /error, so you are seeing this as a fallback". It seems
What other directives do I need to add other than proxy_pass?
Thanks
location /api {
proxy_pass http://vm-name:8081;
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 https;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header Access-Control-Allow-Origin '*';
proxy_max_temp_file_size 0;
proxy_connect_timeout 150;
proxy_send_timeout 100;
proxy_read_timeout 100;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用:
或创建重写规则
You could use that :
or create an rewrite rule