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;
        }
    }
相关文章
相关标签/搜索