下面的這個配置,最後驗證是可以的。只是沒有跳轉
server { listen 80; listen 443 ssl; #ssl on; server_name hc-explorer.h.cash; ssl_certificate /etc/nginx/cert/7d97acd273b4a22.crt; ssl_certificate_key /etc/nginx/cert/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; ssl_prefer_server_ciphers on; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_pass http://localhost:7789; }}
下面這個跳轉成功了
server{ listen 80; server_name hc-explorer.h.cash; rewrite ^ https://$http_host$request_uri? permanent;}server { listen 443 ssl; #ssl on; server_name hc-explorer.h.cash; ssl_certificate /etc/nginx/cert/7d97acd273b4a22.crt; ssl_certificate_key /etc/nginx/cert/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; #ssl_prefer_server_ciphers on; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_pass http://localhost:7789; }}