Nginx根据路径重定向到HTTPS

时间:2020-10-01 13:01:02

标签: nginx

我试图基于路径控制Nginx服务器上的HTTPS重定向。我希望/.well-known/pki-validation / ...保留HTTP,其他所有内容都重定向到HTTPS。我的服务器块设置如下,但是所有内容都重定向到HTTPS。有什么建议吗?

   server {
        # Port to listen on, can also be set in IP:PORT format
        listen  80 default_server;
        server_name _;
        root /opt/bitnami/nginx/html;
    
        location /.well-known/pki-validation/ {

          root /opt/bitnami/nginx/html/well-known/pki-validation;
          allow all;
        }
        location / {
          return 301 https://$host$request_uri;
        }
        # include "/opt/bitnami/nginx/conf/bitnami/*.conf";
    }

0 个答案:

没有答案