最近项目测试环境域名需要配置https,因为自己的博客之前已经配置过https了,以为会很简单,在真的做的时候发现有点坑,所以记录一下,其中主要再nginx下增加如下配置:

    proxy_set_header Host $host:$server_port; #非80端口 ,用80端口时 不需要$server_port
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    

    自己完整配置:

    user  nginx;
    worker_processes  1;
    
    events {
    	worker_connections  1024;
    }
    
    http {
    	include       mime.types;
    	default_type  application/octet-stream;
    	
    	sendfile        on;
    	keepalive_timeout  65;
    	
    	server {
    		listen       2333 ssl;
    		server_name  blog.1992.cool;
    
    		access_log on;
    
    		#ssl on;
    		ssl_certificate /usr/local/ssl/1_blog.1992.cool_bundle.crt;
    		ssl_certificate_key /usr/local/ssl/2_blog.1992.cool.key;
    		ssl_session_timeout 5m;
    		ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    		ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    		ssl_prefer_server_ciphers on;
    		add_header Strict-Transport-Security "max-age=31536000";
    
    		#rewrite ^(.*)$  https://$host$1 permanent;
    
    		location /blog {
    			proxy_set_header Host $host:$server_port;
    			proxy_set_header X-Real-IP $remote_addr;
    			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    			proxy_pass http://127.0.0.1:8080/blog;
    		}
    	}
    }
    

    就这样吧,想到其他的再写。。。

    世界上有一种孤独,不是没人陪你,而是陪你的那个人,根本不懂你。