nginx配置学习记录

  • garens 

nginx中,当配置代理的时候,有时候会出现代理的网址能打开,但登录的时候无法登录,可能的原因是session的问题,在代理的配置文件中加入以下代码可以解决问题:

proxy_pass http://127.0.0.1:9080/app/;

proxy_cookie_path /app/ /;
proxy_cookie_path /app/;
proxy_set_header Host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

配置https:

      #端口监听
      listen       443 ssl;

      #http跳转https
      error_page 497 https://$host:$server_port$uri$is_args$args;
  
      #证书文件名称
      ssl_certificate /etc/nginx/1_webshao.com_bundle.crt;
      #私钥文件名称
      ssl_certificate_key /etc/nginx/2_webshao.com.key;
      ssl_session_timeout 5m;
      #请按照以下协议配置
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
      ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
      ssl_prefer_server_ciphers on;

websocket代理配置

          #websocket代理
          location /websSocket {
          proxy_pass http://192.168.100.3:10192/lyfx-supervisory/webSocket/;
          proxy_http_version 1.1;
          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_read_timeout 120s;
  
          proxy_set_header Upgrade websocket;
          proxy_set_header Connection Upgrade;
      }
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *