我正在爲一個網站設置nginx。我只想設置一些子鏈接到ssl鏈接用戶登錄,註冊.i創建一個讓加密ssl和證書工作正常。我檢查了ssl購物者。我想配置ssl只爲商店不是所有的site.so我重定向商店從80到443,只有商店想工作的SSL。但在我配置了 後,nginx的一些按鈕(javascriptvoid)無法正常工作。它說混合內容,所以當我檢查查看源代碼時,它顯示的按鈕的url仍然是在商店頁面中的http(它應該是https)。SSL不能在nginx 443配置上工作
我檢查一切,我重新配置nginx,檢查tomcat端,都是oky.i不知道什麼是問題。
我的nginx的配置是在這裏爲你
(的(/子)子位置是我想要的工作HTTPS一)
NGINX配置
upstream backend_front {
ip_hash;
server tomcat_serverip:8080;
}
server {
listen 80;
server_name www.domianname.com;
charset utf-8;
access_log /var/log/nginx/80access.log main;
location/{
proxy_pass http://backend_front;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /sub/ {
if ($http_x_forwarded_proto != 'https') {
return 301 https://$server_name$request_uri;
}
proxy_pass http://backend_front;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 443 ssl;
server_name www.domainname.my;
ssl on;
ssl_certificate /etc/letsencrypt/live/fullch.pem;
ssl_certificate_key /etc/letsencrypt/live/privkey.pem;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 15m;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
charset utf-8;
access_log /var/log/nginx/443access.log main;
add_header Strict-Transport-Security "max-age=31536000";
root /data/resources/;
location /sub/ {
proxy_pass http://backend_front;
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 $scheme;
}
location/{
proxy_pass http://backend_front;
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 $scheme;
}
# for static files caching
location ~ .*\.(html|jsp)?$ {
proxy_pass http://backend_front;
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 $scheme;
}
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /data/resources/;
expires 20m;
} # for static files caching -- end
location ~ /favicon\.ico {
root html;
}
location ~ /\. {
deny all;
}
}
查看源代碼結果爲按鈕
<a href="javascript:void(0)" url="http://www.example.com/store/account.htm" onclick="tiaozhuan(this)" style="padding:0px">Manage Account</a>
<a href="javascript:void(0)" url="http://www.example.com/store/order.htm" onclick="tiaozhuan(this)" style="padding:0px">My Orders</a>
當我點擊按鈕這個錯誤messa GE顯示谷歌瀏覽器元素控制檯(但HTTP其工作的罰款。)
jquery-1.8.3.min.js:2 Mixed Content: The page at 'https://www.example.com/store/account.htm' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.example.com/isLogin.htm'. This request has been blocked; the content must be served over HTTPS.
send @ jquery-1.8.3.min.js:2
ajax @ jquery-1.8.3.min.js:2
tiaozhuan @ account.htm:155
onclick @ account.htm:77
請幫我this.i人被困在THI爲近一週我修復this.i不是一個程序員我是系統管理員。和新的nginx.please幫助。
你的nginx配置在哪裏? –
嗨,歡迎來到Stack Overflow,請花一點時間通過[歡迎導覽](https://stackoverflow.com/tour)瞭解你在這裏的方式(並獲得你的第一張徽章),閱讀如何創建一個[Minimal,Complete和Verifiable示例](https://stackoverflow.com/help/mcve)並檢查[如何提出好問題](https://stackoverflow.com/help/how-to-ask ),所以你增加了獲得反饋和有用答案的機會。 – DarkCygnus
@RobertMoskal @RobertMoskal我在這裏輸入nginx配置代碼的main.conf – fatha