大家好,想跟大家請教一個問題。
我有一個web服務,他是軟體本身的,但他不支援https,依據文件說明,他需要使用nginx,來做反向代理,達成https的功能。
但是我在設定上碰到點問題,目前如果使用預設443 Port看起來可以。但是因為防火牆上443被其他占用,所以我只能改成別的Port,但改完以後,似乎有時候頁面切換,他會跳回預設的443,可能是我設定錯誤,所以想請大家幫忙。
#odoo server
upstream xxxx.XXXXXXXXXX.com {
server 127.0.0.1:8099; <<(軟體本身的預設webport)
}
# http -> https
server {
listen 80;
server_name xxxx.XXXXXXXXXX.com;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 9443;
server_name xxxx.XXXXXXXXXX.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Add Headers for odoo proxy mode
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# SSL parameters
ssl on;
ssl_certificate /etc/letsencrypt/live/xxxx.XXXXXXXXXX.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxxx.XXXXXXXXXX.com/privkey.pem;
ssl_session_timeout 30m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-...................................省略:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
# log
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
# Redirect requests to odoo backend server
location / {
proxy_redirect off;
proxy_pass http://xxxx.XXXXXXXXXX.com;
}
# common gzip
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
要不要試
server {
listen 443 ssl;
server_name www.adb.com;
ssl_certificate /etc/ssl/www.www.adb.com.crt;
ssl_certificate_key /etc/ssl/www.www.adb.com.key;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
location / {
proxy_pass https://192.168.2.1:9443;
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 $http_x_forwarded_proto;
}