开发者社区> 问答> 正文

nginx + ssl + tomcat集群,首页可以通过https访问,已登录就成http了

#user  nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;

pid        logs/nginx.pid;

#上面2行原来是注销掉的,没影响,这个是日志
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        #server_name  localhost;
  server_name www.liymao.com; 
        

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
   rewrite ^(.*) https://$server_name$1 permanent; 
        }

  
  
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

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

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

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
 server {
        listen 443;
        server_name www.liymao.com;  # localhost修改为您证书绑定的域名。
        ssl on;   #设置为on启用SSL功能。
        root html;
        index index.html index.htm;
        ssl_certificate cert\1325415_www.liymao.com.pem;   #将domain name.pem替换成您证书的文件名。
        ssl_certificate_key cert\1325415_www.liymao.com.key;   #将domain name.key替换成您证书的私钥文件名。
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  #使用此加密套件。
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #修改protocols。
        ssl_prefer_server_ciphers on;   
    location / {
     root html;   #站点目录。
     index index.html index.htm;   #添加属性。
        }
    location /CloubTripod_Manage {
     proxy_pass http://172.18.85.205:8080/CloubTripod_Manage; #主要是这里,这是tomcat1的端口和项目 
    #    root   html;
        index  index.html index.htm; 
        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_set_header  X-Forwarded-Proto  https;   
        }
    location /CloubTripod_Resuorce {
     proxy_pass http://172.18.85.205:8080/CloubTripod_Resuorce; #主要是这里,这是tomcat1的端口和项目 
    #    root   html;
        index  index.html index.htm; 
        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_set_header  X-Forwarded-Proto  https;   
        }
    location /Jmsez_Manage {
     proxy_pass http://172.18.85.205:8090/Jmsez_Manage; #主要是这里,这是tomcat2的端口和项目</span> 
    #   root   html;
        index  index.html index.htm;
  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_set_header  X-Forwarded-Proto  https; 
        }
    location /Jmsez_Resuorce {
     proxy_pass http://172.18.85.205:8090/Jmsez_Resuorce; #主要是这里,这是tomcat2的端口和项目</span> 
    #   root   html;
        index  index.html index.htm;
  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_set_header  X-Forwarded-Proto  https; 
        }
    location /Patent_Manage {
     proxy_pass http://172.18.85.205:8070/Patent_Manage; #主要是这里,这是tomcat2的端口和项目</span> 
    #   root   html;
        index  index.html index.htm;
  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_set_header  X-Forwarded-Proto  https; 
        }
 location /Patent_Resuorce {
     proxy_pass http://172.18.85.205:8070/Patent_Resuorce; #主要是这里,这是tomcat2的端口和项目</span> 
    #   root   html;
        index  index.html index.htm;
  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_set_header  X-Forwarded-Proto  https; 
        }
    }

}

展开
收起
1546713430193556 2019-01-04 15:35:38 939 0
1 条回答
写回答
取消 提交回答
  • 旺旺:nectar2。
    您好,请检查一下您的程序,是否将登录后跳转的地址设置为http的了。
    2019-01-04 15:47:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里巴巴HTTP 2.0实践及无线通信协议的演进之路 立即下载
CDN助力企业网站进入HTTPS时代 立即下载
《Nginx 代理系统常用手册》 立即下载