[英]Redirect from https to http in Nginx for some urls
I have an Nginx configuration with ssl installed/enabled, and everything works fine, but I need to disable https on certain urls.我有一个安装/启用 ssl 的 Nginx 配置,一切正常,但我需要在某些 url 上禁用 https。 I have tried to achieve this but I'm stuck at the redirect loop between https to http and back.我试图实现这一点,但我被困在 https 到 http 之间的重定向循环中。 Please see my configs in the image below, any help will be appreciated.请在下图中查看我的配置,任何帮助将不胜感激。
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name server_domain.com www.server_domain.com;
root /var/www/html/path_to_app_folder;
index index.php index.html index.htm;
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/server_domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/server_domain/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location ~ ^(/prime.*) {
#default_type text/html;
#return 200 http://$server_name$request_uri;
return 301 http://$server_name$request_uri;
}
} }
Use $scheme
使用$scheme
if ($scheme = https) {
return 301 http://$server_name$request_uri;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.