常用配置路徑代理映射 http和https 配置nginx路徑下的配置文件:/etc/nginx/conf.d/nginx.conf (每個人的可能不一樣,但是我這個就是yum 直接安裝的) 如下配置 配置http 和 https 、ws 和 wss #自定義配置地址upstream halo { ...
常用配置路徑代理映射 http和https
配置nginx路徑下的配置文件:/etc/nginx/conf.d/nginx.conf (每個人的可能不一樣,但是我這個就是yum 直接安裝的)
如下配置 配置http 和 https 、ws 和 wss
#自定義配置地址
upstream halo { server 127.0.0.1:8090; } server { listen 80; listen [::]:80;
#功能變數名稱 server_name *.zengoutlook.online; client_max_body_size 1024m; rewrite ^(.*)$ https://$host$1; # coreHome小程式和ws配置 首碼匹配 location ^~/coreHome/ { proxy_pass http://127.0.0.1:8000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
# 暫時不用 # rewrite ^/coreHome/(.*)$ /$1 break; #攔截標識去除 # proxy_pass http://127.0.0.1:8000; #這裡是http不是ws,不用懷疑,代理的ip和port寫ws訪問的實際地址 # proxy_http_version 1.1; #這裡必須使用http 1.1 #下麵兩個必須設置,請求頭設置為ws請求方式 # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection "upgrade"; } location / { proxy_pass http://halo; proxy_set_header HOST $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } # HTTPS server 配置https server { listen 443 ssl; server_name *.*.online; #自己的功能變數名稱 ssl_certificate /root/ssl/Nginx/1_zeng164outlook.online_bundle.crt; ssl_certificate_key /root/ssl/Nginx/2_zeng164outlook.online.key; ssl_session_timeout 5m; #請按照以下協議配置 ssl_protocols TLSv1.2 TLSv1.3; #請按照以下套件配置,配置加密套件,寫法遵循 openssl 標準。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; fastcgi_param HTTPS on; fastcgi_param HTTP_SCHEME https; # coreHome小程式和ws配置 location ^~/coreHome/ { proxy_pass http://127.0.0.1:8000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # rewrite ^/coreHome/(.*)$ /$1 break; #攔截標識去除 # proxy_pass http://127.0.0.1:8000; #這裡是http不是ws,不用懷疑,代理的ip和port寫ws訪問的實際地址 # proxy_http_version 1.1; #這裡必須使用http 1.1 #下麵兩個必須設置,請求頭設置為ws請求方式 # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection "upgrade"; } location / { proxy_pass http://halo; proxy_set_header HOST $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }