Odoo 9域名www

时间:2016-10-24 09:10:39

标签: nginx openerp

我在odoo上有几个网站。如果我输入像mydatabase.com这样的数据库名称,一切都很好。但如果我进入www.mydatabase.com,它会重定向我的数据库选择器。我怎么能逃避这样的问题? 我的nginx配置:

server {
        listen 80 default_server;
        server_name .local;

        proxy_buffers 16 64k;
        proxy_buffer_size 128k;
        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;
        proxy_read_timeout 600s;
        client_max_body_size 100m;
        location /longpolling {
                proxy_pass http://127.0.0.1:8072;
        }
        location / {
                proxy_pass http://127.0.0.1:8069;
        }
}

Odoo服务器cfg:

[options]
dbfilter = ^%h$
db_template = template1
db_host = False
db_maxconn = 64
db_name = False
db_password = False
db_port = False
auto_reload = False
csv_internal_sep = ,
debug_mode = False
demo = {}
email_from = False
import_partial =
limit_memory_hard = 1205306368
limit_memory_soft = 1005306368
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 120
list_db = True
login_message = False
logrotate = True
longpolling_port = 8072
max_cron_threads = 2
netrpc = False
netrpc_interface =
netrpc_port = 8070
osv_memory_age_limit = 1.0
osv_memory_count_limit = False
pg_path = None
pidfile = False
proxy_mode = False
reportgz = False

1 个答案:

答案 0 :(得分:0)

您应该有两个单独的服务器标头,例如

server {
        listen 80;
        listen [::]:80
        server_name www.example.com;
        return 301 $scheme://mydatabase.com$request_uri;

}


server {
        listen 80 default_server;
        server_name mydatabase.com;

        proxy_buffers 16 64k;
        proxy_buffer_size 128k;
        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;
        proxy_read_timeout 600s;
        client_max_body_size 100m;
        location /longpolling {
                proxy_pass http://127.0.0.1:8072;
        }
        location / {
                proxy_pass http://127.0.0.1:8069;
        }

}

第一个只是用www监听请求并重定向到第二个请求处理代理到odoo的请求

还有其他“更短”的方式,但这是IMO最直接的方式