You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将带端口的Odoo服务IP转为无端口并绑定子域名?

Got it, let's tackle this problem step by step. The core issue here is that DNS records (like CNAME) can't include port numbers, so we need two key things: a reverse proxy to map standard ports (80/443) to Odoo's 8069 port, and proper DNS setup to point your subdomain to the Odoo server. Here's how to do it on your Ubuntu VPS:

1. Set Up Nginx as a Reverse Proxy (Eliminate the Port)

Nginx will act as a middleman: it listens on standard HTTP (80) and HTTPS (443) ports, then forwards traffic to your Odoo instance running on 8069.

First, install Nginx if you don't already have it:

sudo apt update && sudo apt install nginx -y

Next, create a dedicated Nginx configuration file for your subdomain:

sudo nano /etc/nginx/sites-available/shop.example.com

Paste this configuration into the file (replace shop.example.com with your actual subdomain):

server {
    listen 80;
    server_name shop.example.com;

    # Forward all requests to Odoo's port
    location / {
        proxy_pass http://127.0.0.1:8069;
        # Pass important headers to Odoo so it knows the original request details
        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;
    }
}

Save and exit the editor (Ctrl+O, Enter, then Ctrl+X).

Enable the configuration by creating a symbolic link to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/shop.example.com /etc/nginx/sites-enabled/

Test if the Nginx configuration is valid:

sudo nginx -t

If you see "test is successful", restart Nginx to apply changes:

sudo systemctl restart nginx

Update Odoo's Configuration for Proxy Mode

Odoo needs to know it's behind a proxy to handle requests correctly. Open your Odoo configuration file (usually located at /etc/odoo/odoo.conf or ~/odoo/odoo.conf):

sudo nano /etc/odoo/odoo.conf

Add or modify this line to enable proxy mode:

proxy_mode = True

If Odoo is only listening on localhost (which is default), make sure it allows connections from Nginx (though the proxy uses 127.0.0.1 so this is usually fine). If needed, add:

xmlrpc_interface = 0.0.0.0

Save the file and restart Odoo:

sudo systemctl restart odoo
2. Configure DNS Records on OVH

Since you can't use a CNAME to point to an IP with a port, we'll use an A record to map your subdomain directly to the Odoo server's IP:

  1. Log into your OVH Control Panel and navigate to your domain example.com's DNS management section.
  2. Add a new DNS record:
    • Type: A
    • Subdomain: shop
    • Target: Your Odoo server's IP address (95.110.189.135)
    • TTL: Leave as default (e.g., 3600 seconds, which is 1 hour)
  3. Save the record.

Wait for DNS propagation (this can take a few minutes to a few hours, depending on TTL).

To make your site secure and avoid browser warnings, set up an SSL certificate using Let's Encrypt:

Install Certbot and its Nginx plugin:

sudo apt install certbot python3-certbot-nginx -y

Run Certbot to automatically generate and configure the SSL certificate:

sudo certbot --nginx -d shop.example.com

Follow the on-screen prompts:

  • Enter your email address for renewal notifications.
  • Agree to the terms of service.
  • Choose whether to share your email with the Electronic Frontier Foundation (optional).
  • Select option 2 to redirect all HTTP traffic to HTTPS (this is the safer choice).

Certbot will update your Nginx configuration and restart it automatically.

4. Verify Firewall Settings

Make sure your Ubuntu firewall allows traffic on ports 80 and 443:

sudo ufw allow 'Nginx Full'
sudo ufw reload

Now you should be able to access your Odoo instance at https://shop.example.com without needing to append the :8069 port!

内容的提问来源于stack exchange,提问作者Boubaker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:09:47