Odoo
Nginx
I this topic we will explain how to configure nginx for localhost odoo server by steps, but before that you need to install nginx and running odoo server and then follow the steps
First : go to /etc/nginx/enable-sites and add new configuration file by the name odoo14.localhost which will configure your nginx for odoo local server
Second : open the file /etc/hosts and add the localhost (127.0.0.1) to the file as bellow
Third : add the ssl certification by going to etc/ssl and create new folder by name nginx and inside it run the command bellow
openssl req -x509 -new -newkey rsa:2048 -nodes -keyout odoo.key -days 9999 -out odoo.crt
###
odoo14.localhost file will be as
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
# http -> https
server {
listen 80;
#server_name odoo.mycompany.com;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443;
#server_name odoo.mycompany.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 on;
ssl_certificate /etc/ssl/nginx/odoo.crt;
ssl_certificate_key /etc/ssl/nginx/odoo.key;
ssl_session_timeout 30m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
# 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://127.0.0.1:8069;
# common gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript ;
}
}
The hosts file will be as
127.0.0.1 localhost
127.0.1.1 ahmed-HP-EliteBook-8460p
172.0.0.1 localhost.odoo
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
The odoo configuration file will be as
[options]
; This is the password that allows database operations:
admin_passwd = Ahmmar
db_host = False
db_port = 5432
db_name = False
db_user = ahmed
xmlrpc_port = 8069
longpolling_port = 8072
db_password = False
addons_path = /home/ahmed/Desktop/Odoo_14/addons, /home/ahmed/Desktop/Odoo_14/addons/custom_addons
proxy_mode = True
dbfilter = ^%h$
logfile = /var/log/odoo14/odoo14-service.log
###
Here are some important commands
nginx -t >> to test if the nginx conf files are okay
systemctl restart nginx.service >> to restart nginx
sudo su -- >> to login as root user
*NOTE
after doing the above configuration you have to restart the odoo server and go to your browser and open https://localhost which will open the creation page for new database
No comments:
Post a Comment