- Docker and Docker Compose installed
- Basic knowledge of Docker and Nginx
- Domain name configured (e.g.,
domain.com
)
Create a project directory to store your Docker Compose file and Nginx configuration:
mkdir odoo-project
cd odoo-project
Create a .env
file to store environment variables for Odoo and PostgreSQL:
touch .env
Add the following environment variables to the .env
file:
# Odoo environment variables
HOST=localhost
PORT=8069
# PostgreSQL environment variables
POSTGRES_DB=your_db_name
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
Create a docker-compose.yml
file with the following content:
version: "3"
services:
odoo:
image: odoo:15.0
env_file: .env
depends_on:
- postgres
ports:
- "127.0.0.1:8069:8069"
volumes:
- data:/var/lib/odoo
postgres:
image: postgres:13
env_file: .env
volumes:
- db:/var/lib/postgresql/data/pgdata
volumes:
data:
db:
sudo apt update
sudo apt install nginx
sudo ufw allow "Nginx Full"
Create an Nginx configuration file to set up the reverse proxy:
sudo nano /etc/nginx/sites-available/domain_name.com.conf
Add the following content to the file:
server {
listen 80;
listen [::]:80;
server_name my_domain;
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://localhost:8069;
}
}
sudo ln -s /etc/nginx/sites-available/domain_name.com.conf /etc/nginx/sites-enabled/
Test Ngninx Config
sudo nginx -t
Navigate to your project directory and start the Docker containers using Docker Compose:
docker-compose up -d
Restart Nginx to apply the new configuration:
sudo systemctl restart nginx
Open your web browser and navigate to your domain (e.g., http://domain.com
). You should see the Odoo login page.
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d domain.com
You have successfully set up Odoo with Docker and configured Nginx as a reverse proxy. You can now use Odoo with your domain name.