市场上的两大主流 Web 服务器无疑是 Apache 和 Nginx,Odoo 部署为 Web 站点时,显然不会采用 http://your.ip.address:8069的方式进行访问,于我们需要进行 Web 服务器的配置:
Nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# vi /etc/odoo.conf xmlrpc_interface = 127.0.0.1 netrpc_interface = 127.0.0.1 # vi /etc/nginx/conf.d/odoo_nginx.conf upstream odoo { server 127.0.0.1:8069; } upstream odoo-chat { server 127.0.0.1:8072; } server { server_name erp.alanhou.org; # return 301 https://odoo.example.com$request_uri; access_log /var/log/nginx/odoo.access.log; error_log /var/log/nginx/odoo.error.log; proxy_read_timeout 720s; proxy_connect_timeout 720s; proxy_send_timeout 720s; 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; location / { proxy_redirect off; proxy_pass http://odoo; } location /longpolling { proxy_pass http://odoo-chat; } location ~* /web/static/ { proxy_cache_valid 200 90m; proxy_buffering on; expires 864000; proxy_pass http://odoo; } |
Apache
1 2 3 4 5 6 7 8 9 10 |
# vi /etc/httpd/vhost.d/odoo-apache.conf <VirtualHost *:80> ProxyPreserveHost On ProxyRequests Off ServerName erp.alanhou.org ServerAlias erp.alanhou.org ProxyPass / http://localhost:8069/ ProxyPassReverse / http://localhost:8069/ </VirtualHost> |
参考链接:
https://linuxize.com/post/configure-odoo-with-nginx-as-a-reverse-proxy/
常见问题
1、longpolling/poll 502 (Bad Gateway)
1 2 3 4 |
vi /etc/odoo11.conf proxy_mode = True workers = x # x>0 |