Nginx - 如何使用不同的子域名运行多个 Odoo 实例

标签 nginx reverse-proxy odoo-10

我想在不同的链接上运行两个 Odoo v10 实例。
第一个实例将包含多个数据库,用于我们在此链接上运行的测试目的 mydoamin.com

对于第二个实例,我们将为我们的客户提供演示数据库,以便在此链接 clients.mydomain.com 上为他们演示 Odoo

两个实例应该在同一台服务器上运行。
我做了很多研究来弄清楚如何实现这种方法,但我没有找到任何指南可以帮助我通过使用 Nginx 反向代理来做到这一点。

这是我的 Nginx 配置文件:

upstream backend-odoo {
    server 127.0.0.1:8069;
}
upstream backend-odoo-im { 
    server 127.0.0.1:8072; 
}
server {
    listen 80;
    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^/.*$ https://example.com$request_uri? permanent;
}
server {
    listen 443 default;
    # ssl settings
    ssl on;
    ssl_certificate
    /etc/nginx/ssl/cert.pem;
    ssl_certificate_key /etc/nginx/ssl/key.pem;
    keepalive_timeout 60;

    #increase the upload file size limit
    client_max_body_size 300M;

    # proxy header and settings
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;

    # odoo log files
    access_log /var/log/nginx/odoo-access.log;
    error_log /var/log/nginx/odoo-error.log;
    # increase proxy buffer size
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;
    # force timeouts if the backend dies
    proxy_next_upstream error timeout invalid_header http_500
    http_502 http_503;
    # enable data compression
    gzip on;
    gzip_min_length 1100;
    gzip_buffers 4 32k;
    gzip_types text/plain application/x-javascript text/xml text/css;
    gzip_vary on;

    location / {
        proxy_pass http://backend-odoo;
    }
    location ~* /web/static/ {
    # cache static data
    proxy_cache_valid 200 60m;
    proxy_buffering on;
    expires 864000;
    proxy_pass http://backend-odoo;
    }
    location /longpolling { 
        proxy_pass http://backend-odoo-im;
    }
}

附注。我试图设置 db filter = ^%d$在odoo配置文件中,但我什么也没得到。

最佳答案

试试 dbfilter = %h$这对我更有效。
您必须重命名与 URL 匹配的数据库。
yourdomain.com 获取 yourdomain_com 作为数据库名称。

关于Nginx - 如何使用不同的子域名运行多个 Odoo 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43303951/

相关文章:

php - Magento 阻止 Varnish 缓存页面

nginx - 如何在浏览器、nginx服务器中强制下载文件

docker - Traefik/Docker:使用端口作为前端规则(而不是路径或子域)

odoo-9 - 基于访问的表单 View

python - 更新: Odoo project task tags domain

php - nginx 获取 url 的子域并分配文档根目录

nginx - 樱桃 : Do I really need to put it behind a frontend?

Nginx 代理通行证 - 禁用 ipv6

linux - 无法提供端口 80 express.js 反向代理 nginx

postgresql - Odoo filter postgres view 使用向导数据报告日期