# odoo server
upstream odoo-erp {
	server 127.0.0.1:8069;
}

upstream odoo-erp-chat {
	server 127.0.0.1:8071;
}

server {
	listen 80;
	server_name erp.juedt.law;
	proxy_read_timeout 300;
	proxy_connect_timeout 300;
	proxy_send_timeout 300;
	# 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;

	# log files
	access_log /var/log/nginx/erp.juedt.law.access.log;
	error_log /var/log/nginx/erp.juedt.law.error.log;

	# redirect requests to odoo backend server
	location / {
		proxy_redirect off;
		proxy_pass http://odoo-erp;
	}

	location /longpolling {
		proxy_pass http://odoo-erp-chat;
	}

	# common gzip
	gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
	gzip on;
}
