Odoo利用Nginx配置HTTPS

Odoo利用Nginx配置HTTPS

前提是已经有一个域名已指向odoo服务器ip,注意需提前申请好https证书。

Odoo-Nginx示例配置:

upstream odoo {
     server 127.0.0.1:8069;   # 本地odoo地址
}
upstream odoochat {
     server 127.0.0.1:8072;
}

# http -> https
server {
   listen 80;
   server_name odoo.mycompany.com; #你的域名
   rewrite ^(.*) https://$host$1 permanent;
}

server {
 listen 443;
 server_name odoo.mycompany.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 - update with your cert details
 ssl on;
 ssl_certificate /etc/ssl/nginx/server.crt;     # 证书路径
 ssl_certificate_key /etc/ssl/nginx/server.key; # 证书路径
 ssl_session_timeout 30m;
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!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;  # log文件位置
 error_log /var/log/nginx/odoo.error.log;    # error文件位置

 # Redirect requests to odoo backend server
 location / {
   proxy_redirect off;
   proxy_pass http://odoo;
 }
 location /longpolling {
     proxy_pass http://odoochat;
 }

 # common gzip
 gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
 gzip on;
}

注意修改证书和文件的路径

测试nginx配置并重启它:

nginx -t
service nginx restart
Last modification:June 26th, 2019 at 11:09 am
If you think my article is useful to you, please feel free to appreciate

5 comments

  1. 高中作文

    感谢分享

  2. 张先生

    你的歌很不错,可以分享一个你的个人歌单吗?我下班坐地铁有时不知道好听的是什么|´・ω・)ノ

    1. 博主
      @张先生

      网易歌单: https://music.163.com/playlist?id=2615198893&userid=1339964216

  3. 丘八

    写的很好,支持一下

  4. 简单生活

    大佬,这里干货满满啊!

Leave a Comment