2016-10-21 77 views
0

我需要從url後端口號。我正在使用--db-filter ='^%d @'運行odoo實例,mydomain.com:8069工作正常,但mydomain.com正在獲取頁面未找到。我已經安裝了nginx並編輯瞭如下的/etc/nginx/nginx.conf隱藏URL odoo中的端口號?

/etc/nginx/nginx.conf

#user nobody; 
worker_processes 1; 

events { 
    worker_connections 1024; 

} 

http { 
    include  mime.types; 
    # anything written in /opt/nginx/conf/mime.types is interpreted as if written inside the http { } block 

    default_type application/octet-stream; 
    # 

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
#     '$status $body_bytes_sent "$http_referer" ' 
#     '"$http_user_agent" "$http_x_forwarded_for"'; 

#access_log logs/access.log main; 

sendfile  on; 


keepalive_timeout 65; 


server { 
    # You would want to make a separate file with its own server block for each virtual domain 
    # on your server and then include them. 

    listen  8069; 
    listen  192.168.1.111:8080; 
    listen  192.168.1.111; 
    #tells Nginx the hostname and the TCP port where it should listen for HTTP connections. 
    # listen 80; is equivalent to listen *:80; 

#server_name localhost; 
    server_name mydomain.com; 
    server_name www.mydomain.com; 
    # lets you doname-based virtual hosting 

    #charset koi8-r; 

    #access_log logs/host.access.log main; 

    location/{ 
     #The location setting lets you configure how nginx responds to requests for resources within the server. 
     root html; 
     index index.html index.htm; 
    } 

    #error_page 404    /404.html; 

    # redirect server error pages to the static page /50x.html 
    # 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root html; 
    } 


} 
} 

我怎樣才能做到這一點?建議任何解決方案..

+0

您需要讓您的應用程序可以從默認端口訪問。 HTTP的端口80和HTTPS的端口443。 –

+0

可expalin我該怎麼做..我編輯哪個文件? – KbiR

+0

您希望apache/nginx能夠接收端口80並重定向到端口8069.如果您考慮使用反向代理(GOOGLE)運行odoo,您會發現它。這裏是關於這個問題的討論。有許多。 https://www.odoo.com/forum/help-1/question/nginx-reverse-proxy-on-80-443-32052 –

回答

0

請嘗試以下服務器配置。如果你願意,你可以把它放在一個單獨的文件中,並將其包含在主要的nginx.conf中。

upstream odoo { 
    server 127.0.0.1:8080; # Or wherever your Odoo service is listening 
} 

server { 
    server_name mydomain.com; 
    listen  0.0.0.0:80; 

    root /var/www/html/odoo/; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ @odoo; 
    } 

    location @odoo { 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://odoo; 
    } 
} 

簡而言之,它定義了odoo服務的上游服務器odoo。當收到請求時(比如說mydomain.com/path/to/resource),nginx會嘗試通過從根目錄提供它應該提供的相應資源來處理它。如果失敗,它會重試,並附加斜槓。如果這也失敗了,它會將路徑發送到上游服務器(odoo)進行處理。