run odoo with nginx at port 80

December 16, 2017 268 views
Nginx Ubuntu

hi,
I have an odoo instance running at http://www.johnstonebros.ie:8069/
I want to run it at default port 80 with nginx server.
my nginx is working at http://www.johnstonebros.ie:8000

How can port 8069 to 80? Thanks.

1 Answer

You can configure Nginx to proxy all requests to port 8069.
Start by creating a server block for your domain by following the How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04 tutorial.

Once you're done, open the newly-created server block in text editor.
Locate the locate / block under the server block. It should look like the following one:

...
    location / {
        try_files $uri $uri/ =404;
    }
...

Replace it with the below one:

...
    location / {
        proxy_pass http://localhost:8069;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
...

Save the file and close your text editor. You can check Nginx's configuration files to make sure they're correctly typed:

  • sudo nginx -t

You should see output mentioning tests are passing successfully.

Output
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

Lastly, to put changes in the effect, reload Nginx.

  • sudo systemctl reload nginx

This should do the job. When you point web browser to your domain, you should see Oddo running there.

When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu...
Have another answer? Share your knowledge.