【问题标题】:Hide port number in URL odoo?在 URL odoo 中隐藏端口号?
【发布时间】:2017-03-03 08:54:35
【问题描述】:

我需要从 url 中隐藏端口号。我正在使用 --db-filter='^%d@' 运行 odoo 实例,mydomain.com:8069 工作正常,但 mydomain.com 找不到页面。我已经安装了 nginx 并编辑了/etc/nginx/nginx.conf 如下。

/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;
    }


}
}

我该怎么做?提出任何解决方案..

【问题讨论】:

  • 您需要让您的应用程序可以从默认端口访问。用于 HTTP 的端口 80 和来自 HTTPS 的端口 443。
  • 能否解释我该怎么做.. 我编辑哪个文件?
  • 您希望 apache/nginx 接收端口 80 并重定向到端口 8069。如果您查看使用反向代理 (GOOGLE) 运行 odoo,您会发现它。这是关于这个问题的讨论。有许多。 odoo.com/forum/help-1/question/…

标签: nginx openerp port reverse-proxy odoo-8


【解决方案1】:

尝试以下服务器配置。你可以把它放在一个单独的文件中,如果你愿意,可以把它包含在主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)进行处理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 1970-01-01
    • 2020-10-13
    • 1970-01-01
    • 1970-01-01
    • 2014-01-17
    • 2016-11-13
    相关资源
    最近更新 更多