
Proxy Pass odoo 8069 to 80 with enhancements
This post was intended to document what i’ve done during my spare time on afternoon – 14/01/2018 for my internal team
But since the post public then i assume this could be useful for any of odoo devOps out there
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
Lets get start
To prevent unwanted halt on the services i suggest you to perform swap creation, swap creation could be found on this link
Now, lets install nginx on your web server machine
sudo apt-get install nginx
after installing nginx create a proxy pass configuration on /etc/nginx/sites-available name it 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; } }
as seen on : https://wiki.archlinux.org/index.php/Odoo#Using_Nginx
save the file and now heading to /etc/nginx/sites-enabled and soft link the previous created file with
ln -s ../sites-available/odoo odoo
and remove the default config
rm -rf default
lets run sudo nginx -t to check your configuration it should return
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
now your application should be run on port 80 or your root domain without problem
http://yourdomain.com
the nextstep would be useful if you want to redirect your 8069 port to port 80
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8069 -j REDIRECT --to-port 80
this will redirect your existing 8069 port to port 80
your odoo application now should be able to run on port 80 only
*optional
if you want to make your site secure with https, i suggest use certbot services and follow the steps here
https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx
This will allow your application run on secure protocol https
happy coding!