如何覆盖NGINX中从Http到Https的某些外部URL中的一个?

时间:2019-03-04 18:08:15

标签: http nginx https

我拥有的大多数外部请求都是Https。但我也有4 http。如何配置NGINX配置以便将所有http外部查询替换为Https?

enter image description here 这是我的Nginx配置:

server {
    listen 80;
    server_name digitalcommerce.ml www.digitalcommerce.ml;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    send_timeout 600;

    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
    }
}

server {
   listen 443 ssl;
   server_name digitalcommerce.ml www.digitalcommerce.ml;   

   ssl_certificate /etc/letsencrypt/live/digitalcommerce.ml/fullchain.pem;
   ssl_certificate_key /etc/letsencrypt/live/digitalcommerce.ml/privkey.pem;
   ssl_trusted_certificate /etc/letsencrypt/live/digitalcommerce.ml/chain.pem;

   proxy_connect_timeout 600;
   proxy_send_timeout 600;
   send_timeout 600;

    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
    }
}

0 个答案:

没有答案