Nginx 強制 HTTPS 配置


Nginx 強制 HTTPS 配置

server {
            listen 443 ssl;
            server_name example.com;
            ssl_certificate     /cert/example.com.pem;
            ssl_certificate_key /cert/example.com.key;

            access_log  off;
            location / {
                proxy_redirect     off;
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_pass http://localhost:5000;
            }
}

server {
            listen 80;
            server_name example.com;
            return 301 https://$server_name$request_uri;
}

注意:需要將 server_name、proxy_pass、ssl_certificate、ssl_certificate_key 改為自己的值。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM