Proxy Pass odoo 8069 to 80 with enhancements
There are couple of things that you should be familiar before going through the steps
Odoo
Linux
Nginx
So i assume the application was now accessible through your port 8069, eg. 188.xx.xx.xx:8069 or yourdomain.com:8069 and your requirement would be
your application should be run on port 80, or your domain eg: yourdomain.com
your application should be run under secure connection
your application should not be accessible through port 8069 anymore
sudo apt-get install nginx -y
nano /etc/nginx/sites-available/odoo
upstream odoo {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name yourdomain.com;
root /usr/share/nginx/html;
index index.html index.htm;
access_log /var/log/nginx/yourdomaincom.access.log;
error_log /var/log/nginx/yourdomaincom.error.log;
location / {
proxy_pass http://odoo;
# force timeouts if the backend dies
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
# set headers
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 https;
}
# cache some static data in memory for 60mins
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}
}
Save and exit
cd /etc/nginx/sites-enabled/
ln -s ../sites-available/odoo odoo
rm -rf default
cd /etc/nginx/sites-available/
rm -rf default
nginx -t
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8069 -j REDIRECT --to-port 80
sudo /etc/init.d/nginx restart
sudo systemctl restart odoo
Open URL http://localhost or http://ip
How To Secure Apache with Let's Encrypt on Ubuntu 22.04
Step 1 — Installing Certbot
sudo apt update
#sudo apt install certbot python3-certbot-apache -y
sudo apt-get install python3-certbot-nginx -y
Step 2 — Checking your Apache Virtual Host Configuration
#sudo nano /etc/apache2/sites-available/your_domain.conf
sudo nano /etc/nginx/sites-available/your_domain.conf
...
ServerName your_domain
ServerAlias www.your_domain
...
#sudo apache2ctl configtest
nginx -t
#sudo systemctl reload apache2
sudo /etc/init.d/nginx restart
sudo systemctl reload nginx
/etc/init.d/nginx restart
sudo systemctl restart odoo
Step 3 — Allowing HTTPS Through the Firewall
sudo ufw status
sudo ufw allow 'Apache Full'
# sudo ufw delete allow 'Apache'
sudo ufw status
Step 4 — Obtaining an SSL Certificate
#sudo certbot --apache
sudo certbot --nginx -d my_subdomain.website.com -d my_subdomain2.website.com
Output
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): you@your_domain
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: your_domain
2: www.your_domain
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Output
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/your_domain/fullchain.pem
Key is saved at: /etc/letsencrypt/live/your_domain/privkey.pem
This certificate expires on 2024-08-23.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
Deploying certificate
Successfully deployed certificate for your_domain to /etc/apache2/sites-available/your_domain-le-ssl.conf
Successfully deployed certificate for www.your_domain.com to /etc/apache2/sites-available/your_domain-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https:/your_domain and https://www.your_domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Step 5 — Verifying Certbot Auto-Renewal
sudo systemctl status certbot.timer
Output
● certbot.timer - Run certbot twice daily
Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset:>
Active: active (waiting) since Mon 2024-08-23 20:52:46 UTC; 4min 3s ago
Trigger: Tue 2024-11-23 00:56:55 UTC; 4h 0min left
Triggers: ● certbot.service
May 31 20:52:46 jammy-encrypt systemd[1]: Started Run certbot twice daily.
sudo certbot renew --dry-run
Output
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/your_domain.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for your_domain and www.your_domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
/etc/letsencrypt/live/your_domain/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -