Once your Odoo is configured and running on the IP with port then proceed with Nginx configuration. Confused?? How to install Odoo? Click on this link to explore and understand.
Nginx:
A high-performance web server called NGINX was created to meet the growing demands of the modern web. High performance, lots of parallelisms, and sparse resource utilization are its main priorities.
NGINX is a reverse proxy server at its core, despite being primarily recognized as a web server.
But, there are other web servers available besides NGINX. The 1995-first-released Apache HTTP Server (httpd) is one of its main rivals.
Although Apache HTTP Server is more flexible, server administrators frequently favor NGINX for the following two reasons:
- It is able to manage more concurrent queries.
- It uses fewer resources and delivers static content more quickly.
Step 1: Install and configure Nginx with reverse proxy.
First, use the command below to install nginx on the server.
1 |
sudo apt-get install nginx -y |
Then, Create/Edit the domain server block.
1 |
sudo vim /etc/nginx/sites-enabled/yourdomain.com.conf |
Copy the configuration from below, paste it into your file, and make the necessary adjustments. Below mentioned configuration will work for the Odoo version >= 16.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
#odoo server upstream odoo { server 127.0.0.1:8069; } upstream odoochat { server 127.0.0.1:8072; } map $http_upgrade $connection_upgrade { default upgrade; '' close; } #To redirect non-existing domain to your custom page #Note - If you do not have any specific location to redirect then, remove the location block and just add the "return 400". server { listen 80 default_server; server_name _; location / { rewrite ^(.*)$ https://domain_to_be_redirected.com$request_uri permanent; } } server { listen 443 default_server; server_name _; ssl_certificate /path/to/ssl/cert; ssl_certificate_key /path/to/ssl/cert; location / { rewrite ^(.*)$ https://domain_to_be_redirected.com$request_uri permanent; } } # http -> https server { listen 80; server_name yourdomain.com; rewrite ^(.*) https://$host$1 permanent; } server { listen 443 ssl; server_name yourdomain.com; proxy_read_timeout 720s; proxy_connect_timeout 720s; proxy_send_timeout 720s; # SSL parameters ssl_certificate /etc/ssl/nginx/server.crt; ssl_certificate_key /etc/ssl/nginx/server.key; ssl_session_timeout 30m; ssl_protocols TLSv1.2; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; ssl_prefer_server_ciphers off; # log access_log /var/log/nginx/odoo.access.log; error_log /var/log/nginx/odoo.error.log; # Redirect websocket requests to odoo gevent port location /websocket { proxy_pass http://odoochat; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } # Redirect requests to odoo backend server location / { # Add Headers for odoo proxy mode proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; proxy_pass http://odoo; } # common gzip gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript; gzip on; } |
If you have installed the Odoov <= 15.0, Then use the below-mentioned configuration file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
#odoo server upstream odoo { server 127.0.0.1:8069; } upstream odoochat { server 127.0.0.1:8072; } #To redirect non-existing domain to your custom page #Note - If you do not have any specific location to redirect then, remove the location block and just add the "return 400". server { listen 80 default_server; server_name _; location / { rewrite ^(.*)$ https://domain_to_be_redirected.com$request_uri permanent; } } server { listen 443 default_server; server_name _; ssl_certificate /path/to/ssl/cert; ssl_certificate_key /path/to/ssl/cert; location / { rewrite ^(.*)$ https://domain_to_be_redirected.com$request_uri permanent; } } # http -> https server { listen 80; server_name yourdomain.com; rewrite ^(.*) https://$host$1 permanent; } server { listen 443 ssl; server_name yourdomain.com; proxy_read_timeout 720s; proxy_connect_timeout 720s; proxy_send_timeout 720s; # Add Headers for odoo proxy mode proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; # SSL parameters ssl_certificate /etc/ssl/nginx/server.crt; ssl_certificate_key /etc/ssl/nginx/server.key; ssl_session_timeout 30m; ssl_protocols TLSv1.2; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; ssl_prefer_server_ciphers off; # log access_log /var/log/nginx/odoo.access.log; error_log /var/log/nginx/odoo.error.log; # Redirect longpoll requests to odoo longpolling port location /longpolling { proxy_pass http://odoochat; } # Redirect requests to odoo backend server location / { proxy_redirect off; proxy_pass http://odoo; } # common gzip gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript; gzip on; } |
Once you’re done with the Nginx configuration, test the Nginx configuration & restart the Nginx service with the blow mentioned command.
1 2 |
nginx -t sudo systemctl restart nginx |
For configuring the Free Self-signed certificates from let’s encrypt, Please click on this link.
Restart the Odoo server as well as the PostgreSQL service.
1 2 |
sudo service postgresql restart sudo /etc/init.d/odoo16-server restart |
Once both services are up, hit the domain in the browser.
Note – Do not forget to open the 80 & 443 ports from the AWS console in Security Group.
1 |
https://yourdomain.com |
After login, you will get the below-attached page.
If you find this blog helpful, Please give us your valuable time to provide us feedback for the same.
Need Support?
Thank You for reading this Blog!
For further more interesting blogs, keep in touch with us. If you need any kind of support, simply raise a ticket at https://webkul.uvdesk.com/en/.
You may also visit our Odoo development services and quality Odoo Extensions.
For further help or query, please contact us or raise a ticket.