Nginx 配置问题
本文介绍了Nginx 配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
这个 server 的目的是让访问 80 端口的请求重定向到 https,但是我有个服务不想走 https,于是我加了 location 这一段,但是这样配置不行,请求这个路径还是会重定向,应该如何配置?
server {
listen 80;
server_name example.me www.example.me;
location /service/upload {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1031/upload;
}
return 301 https://www.example.me$request_uri;
}
解决方案
server {
listen 80;
server_name example.me www.example.me;
location /service/upload {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1031/upload;
}
location / {
rewrite ^/(.*) https://www.example.me/$1 permanent;
}
}
这篇关于Nginx 配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文