我将我的Nginx配置为将所有http请求重定向到https。
server {
server_name url.net;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
return 301 https://$host$request_uri;
}
server {
server_name url.net;
listen 443 ssl http2 ;
....
}在url.net/file.xml中有一个特定的资源,我希望允许简单的HTTP请求,而不需要任何重定向。
我如何在nginx中配置它?
发布于 2017-10-30 16:04:05
将return语句放置到location块中,然后为URI异常添加一个完全匹配的location块。详情请参见本文件。
例如:
server {
server_name url.net;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
return 301 https://$host$request_uri;
}
location = /file.xml {
root /path/to/directory;
}
}请注意,如果您的安全站点上有头,这将不会使工作。
https://stackoverflow.com/questions/47018705
复制相似问题