https方式nginx 代理tomcat訪問不帶www的域名301重定向跳轉到www的域名幫助seo集中權重

好比我要把nginx

http://gucanhui.comtomcat

http://www.gucanhui.comsession

跳轉到https://www.gucanhui.comui

用F12的network能夠看到狀態碼301,必定不能是302spa

須要注意的是,只須要nginx開啓ssl就好了,tomcat和nginx仍是走http就行code

因此證書配置,只須要在nginx上配置server

配置http不帶www的跳轉到https帶www的blog

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

而後http帶www的跳轉到https帶www的ip

server {
        listen       80;
        server_name  www.gucanhui.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            
            return       301 https://www.gucanhui.com$request_uri;
        }

而後再443端口配置證書和跳轉就好了ssl

 # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  www.gucanhui.com;
 
         ssl_certificate     gucanhui.com.crt;
        ssl_certificate_key  gucanhui.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            proxy_pass http://127.0.0.1:8080;
        }
    }
相關文章
相關標籤/搜索