How Can We Help?

使用 NGINX 作為 Reverse Proxy 加速 Odoo

You are here:
< All Topics

要加速 Odoo 可以從幾個方向著手:

  • 調整 Odoo 的 config 檔
  • 調整 PosgreSQL 的 config 檔
  • 使用 NGINX 作為 Reverse Proxy(反向代理),甚至進一步開啟 HTTP/2(需一併設定 SSL)

我們在這一篇會著重在設定 NGINX 作為 Reverse Proxy

編輯 NGINX 的 conf 檔

 vim /etc/nginx/conf.d/odoo.conf

內容設定為

server {
    listen       80;
    server_name  192.168.1.244 odoo.glamping.tw;

    location  / {
        proxy_pass http://odoo.gapl.com.tw;
        proxy_buffer_size 128k;
        proxy_buffers 16 64k;
        proxy_redirect off;
        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 ~* /web/static/ {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://odoo.gapl.com.tw;
    }

    error_page   500 502 503 504  /50x.html;
#    location = /50x.html {
#        root   /usr/share/nginx/html;
#    }
}

關於其中的參數可以參考 Understanding Nginx HTTP Proxying, Load Balancing, Buffering, and Caching 這篇

REVERSE PROXY WITH ODOO 8 | NGINX | UBUNTU 14.04 LTS | LONGPOLLING 這篇

建議加大  proxy_buffer_size 與 proxy_buffers 才能處理 Odoo 的 Web requests

設定完後,重新啟動 NGINX 就可以進行測試囉

 

 

/etc/letsencrypt/live/odoo.glamping.tw/fullchain.pem

注意事項:

NGINX 設定檔中的 proxy_pass 參數如果有加入 port 號,NGINX 會啟動失敗,不確定原因

 

參考資料:

REVERSE PROXY WITH ODOO 8 | NGINX | UBUNTU 14.04 LTS | LONGPOLLING

Install Odoo on a Debian 8 VPS with Nginx as a reverse proxy

Setting Up OpenERP (Odoo) 9 with Nginx on RHEL/CentOS and Debian/Ubuntu

Running Odoo with nginx in https mode

Understanding Nginx HTTP Proxying, Load Balancing, Buffering, and Caching

Table of Contents