# Nginx configuration with rewrite does not shown database list

**URL:** https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605
**Category:** System Administrator
**Created:** [April 18, 2020, 9:02am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605 "2020-04-18T09:02:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![mboscolo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/mboscolo/32/781_2.png) [@mboscolo](https://discuss.tryton.org/u/mboscolo)
#### Post date: [April 18, 2020, 9:02am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/1 "2020-04-18T09:02:46Z")

</div>

Dear All,  
I set up tryton successfully on vps server.  
and if I set the configuration file like this

```
[database]
uri = postgresql://tryton:tryton@localhost/
path = /opt/tryton/bin/trytond
[web]
root = /opt/tryton/sao
;hostname = http://mydomain.org
listen = 0.0.0.0:8000
num_proxies=1

```

everything works well

if I change the listen to localhost and I use the reverse proxy, the sao client appear correctly but I’m not able to see the database list. Also if I try to fill up data into login form I get a generic error !!!

This is my nginx configuration:

```
upstream tryton {
  server 127.0.0.1:8000;
}

server {
  listen 80;
  server_name *.mydomain.org;

# Redirect requests 
  location /tryton/ {
             rewrite ^/tryton/(.*)$ /$1 break;
             proxy_pass http://tryton/;
             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-Host $server_name;
             }

```

I also try to setup the hostname like this:

`hostname = http://mydomain.org`

but I’m not able to login, and the server log dose not show useful information.

```
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET / HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/jquery/dist/jquery.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/moment/min/locales.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/moment/min/moment.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/gettext.js/dist/gettext.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/bootstrap/dist/js/bootstrap.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/d3/d3.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/fullcalendar/dist/locale-all.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/mousetrap/mousetrap.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/fullcalendar/dist/fullcalendar.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/c3/c3.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/papaparse/papaparse.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/Sortable/Sortable.js HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/bootstrap/dist/css/bootstrap.min.css HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/bootstrap-rtl-ondemand/dist/css/bootstrap-rtl-ondemand.min.css HTTP/1.0" 304 -
Sat Apr 18 08:37:05 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:05] "GET /bower_components/fullcalendar/dist/fullcalendar.min.css HTTP/1.0" 304 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css HTTP/1.0" 304 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /bower_components/c3/c3.min.css HTTP/1.0" 304 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /dist/tryton-sao.min.js HTTP/1.0" 304 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /dist/tryton-sao.min.css HTTP/1.0" 304 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /custom.js HTTP/1.0" 405 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /custom.css HTTP/1.0" 405 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /custom.js HTTP/1.0" 405 -
Sat Apr 18 08:37:06 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:06] "GET /custom.css HTTP/1.0" 405 -
Sat Apr 18 08:37:07 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:07] "GET /images/tryton-menu.svg HTTP/1.0" 200 -
Sat Apr 18 08:37:07 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:07] "GET /locale/en_GB.json HTTP/1.0" 405 -
Sat Apr 18 08:37:07 2020] INFO:werkzeug:5.170.192.20 - - [18/Apr/2020 08:37:07] "GET /locale/en.json HTTP/1.0" 405 -

```

any help will be very appreciated

regards,  
Matteo

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 18, 2020, 10:47am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/2 "2020-04-18T10:47:39Z")

</div>

> [@mboscolo](#):
>
> location /tryton/ {  
> rewrite ^/tryton/(.\*)$ /$1 break;  
> proxy\_pass [http://tryton/](http://tryton/);  
> proxy\_set\_header Host $host;  
> proxy\_set\_header X-Real-IP $remote\_addr;  
> proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

Why you are redirecting only tryton requests? Is tryton the name of your database?  
If you use a diferent database it will not work.

Why you need to rewrite?

We use nginx in front of the docker image (basically to manage multiple hosts on the same server and ssl certificates). We use a single route to redirect all request as seen below:

```
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://localhost:8000;
        }

```

Hope this is usefull.

---

<div class="post-metadata">

### Author: ![mboscolo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/mboscolo/32/781_2.png) [@mboscolo](https://discuss.tryton.org/u/mboscolo)
#### Post date: [April 18, 2020, 10:53am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/3 "2020-04-18T10:53:08Z")

</div>

Dear Pokoli,  
thanks for your quick response.

I have a flask website that use tryton as model object, I wold like to give access to tryton sao interface as website back and to manage it

[DOMAIN FOR SALE](http://www.myDomain.org/tryton) will give the tryton login.

Regards,  
Matteo

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 18, 2020, 11:23am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/4 "2020-04-18T11:23:13Z")

</div>

> [@mboscolo](#):
>
> have a flask website that use tryton as model object, I wold like to give access to tryton sao interface as website back and to manage it
> 
> [www.myDomain.org/tryton](http://www.myDomain.org/tryton) will give the tryton login.

That clarifies things a little bit.

I’m not an nginx expert but as far as I understand you don’t need to rewrite the path. Just use two locations and forward each one to the required upstream server. Something like this:

```auto
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://flask;
        }

        location /tryton/ {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://tryton;
        }

```

See [this article](https://www.liaohuqiu.net/posts/nginx-proxy-pass/) for more complete examples or the [nginx documentation about proxy\_pass.](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass)

---

<div class="post-metadata">

### Author: ![mboscolo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/mboscolo/32/781_2.png) [@mboscolo](https://discuss.tryton.org/u/mboscolo)
#### Post date: [April 18, 2020, 11:45am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/5 "2020-04-18T11:45:42Z")

</div>

I already check the nginx documentation.  
even with the method you suggest I get the some behaviour as before  
the login fails . and not database is selected.  
the problem is that in the log of tryton and in the log of the browser i do not have any information !!!

I also try in this way but with no success

> location ~ ^/tryton/(.\*)$ {  
> proxy\_pass [http://192.169.154.102:9999/$1](http://192.169.154.102:9999/$1);  
> }

regards  
Matteo

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 18, 2020, 12:07pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/6 "2020-04-18T12:07:40Z")

</div>

> [@mboscolo](#):
>
> the problem is that in the log of tryton and in the log of the browser i do not have any information !!!

You can use the -v flag (more flags more logging details) to increase trytond logging. Or you can set a [custom logging configuration](https://docs.tryton.org/projects/server/en/latest/topics/logs.html)

> [@mboscolo](#):
>
> the login fails . and not database is selected.

If no database is listed this means that you are not connecting with the right server. So for me the problem is on the nginx configuration.

> [@mboscolo](#):
>
> location ~ ^/tryton/(.\*)$ {  
> proxy\_pass [http://192.169.154.102:9999/$1;](http://192.169.154.102:9999/%241;)  
> }

This may be the clue to solve the problem. By default tryton will only listen to 127.0.0.1 and not to the lan IP (192.168.154.102).

Did you tried using localhost or 127.0.0.1? (which is the same).

---

<div class="post-metadata">

### Author: ![mboscolo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/mboscolo/32/781_2.png) [@mboscolo](https://discuss.tryton.org/u/mboscolo)
#### Post date: [April 18, 2020, 12:09pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/7 "2020-04-18T12:09:29Z")

</div>

> [@pokoli](#):
>
> This may be the clue to solve the problem. By default tryton will only listen to 127.0.0.1 and not to the lan IP (192.168.154.102).

copy paste error in the server is correct because the login page appear

---

<div class="post-metadata">

### Author: ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)
#### Post date: [April 18, 2020, 12:12pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/8 "2020-04-18T12:12:58Z")

</div>

> [@mboscolo](#):
>
> [www.myDomain.org/tryton](http://www.myDomain.org/tryton) will give the tryton login.

I think it is quite difficult to get Tryton/Sao to work if it is in a subpath. If I am not mistaken, after the login page is served from [DOMAIN FOR SALE](http://www.myDomain.org/tryton) the subsequent POST requests from Sao go back to [www.myDomain.org](http://www.myDomain.org) and not [DOMAIN FOR SALE](http://www.myDomain.org/tryton). This is why it works with `listen = 0.0.0.0:8000`, because in this case trytond is replying directly to the POST requests, instead of via nginx.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 18, 2020, 12:23pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/9 "2020-04-18T12:23:23Z")

</div>

> [@mboscolo](#):
>
> copy paste error in the server is correct because the login page appear

Are you sure? Note that nginx will cache all the static files so if your seen the page on time it will be shown correctly when the server is not properly configurad.

You can see in your logs from frist post that it responds with 304 ( which means no modified ) so the server does not send any file and the browser loads the files from it’s cache.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 18, 2020, 12:46pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/10 "2020-04-18T12:46:59Z")

</div>

Indeed as far as I know subpath is not really working. But if someone wants to propose a patch to support it, it will be welcomed (even if it is not really a priority).

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 18, 2020, 12:59pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/11 "2020-04-18T12:59:46Z")

</div>

I’ve tested and I can confirm that it’s not working. I’ve started to write a patch but it is not fully working. I can logging but the menu screen is not properly loading. I need some more time to test it.

I will share my process latter.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 18, 2020, 1:37pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/12 "2020-04-18T13:37:17Z")

</div>

I’ve filled [Allow to deploy sao on subpath (#9239) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9239) which add soport for supbath on sao.

@mboscolo could you please apply it to your setup and test it works correctly?  
I’ve also posted on the issue the required nginx configuration to make it work.

---

<div class="post-metadata">

### Author: ![mboscolo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/mboscolo/32/781_2.png) [@mboscolo](https://discuss.tryton.org/u/mboscolo)
#### Post date: [April 19, 2020, 7:41am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/13 "2020-04-19T07:41:28Z")

</div>

Dear @pokoli I check the patch and I’m able to see the database list and login correctly to the sao client.  
I also try to create and save entity and it looks to work smoothly.

many thanks for the patch.

regards,  
Matteo

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [May 18, 2020, 7:02pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/14 "2020-05-18T19:02:08Z")

</div>

> [@pokoli](#):
>
> We use nginx in front of the docker image (basically to manage multiple hosts on the same server and ssl certificates). We use a single route to redirect all request as seen below:

Don’t you proxy only the POST requests and use nginx to serve SAO?

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [May 19, 2020, 6:55am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/15 "2020-05-19T06:55:39Z")

</div>

> [@josesalvador](#):
>
> Don’t you proxy only the POST requests and use nginx to serve SAO?

No because we use the sao images which already contains sao and are configured to server it’s static content. So we use nginx to proxy the request directly to the container, manage ssl certificates (using letsencrypt).

This allows to receive all updates (python code and sao) by pulling the docker images.

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [May 19, 2020, 7:53am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/16 "2020-05-19T07:53:30Z")

</div>

> [@pokoli](#):
>
> No because we use the sao images which already contains sao and are configured to server it’s static content.

I guess you mean Tryton docker image, don’t you?

So SAO is served from Tryton through uwsgi.

We mount SAO from Tryton docker image in a nginx container to serve SAO from there. We thought that maybe Nginx would be more efficient in this task than uwsgi. Do you think it is worth to serve SAO from nginx instead of uwsgi?

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [May 19, 2020, 8:37am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/17 "2020-05-19T08:37:20Z")

</div>

> [@josesalvador](#):
>
> We mount SAO from Tryton docker image in a nginx container to serve SAO from there. We thought that maybe Nginx would be more efficient in this task than uwsgi. Do you think it is worth to serve SAO from nginx instead of uwsgi?

As we have nginx installed on the host (we redirect based on the host to diferent ports environments) we do no think we need an extra container for serving static files. But normally there is no way that works for all.

---

<div class="post-metadata">

### Author: ![German](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/german/32/143_2.png) [@German](https://discuss.tryton.org/u/German)
#### Post date: [May 20, 2020, 2:16am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/18 "2020-05-20T02:16:08Z")

</div>

Hello Mateo,  
I’m working on trytond 5.0 version how did you applied this patch? I’m facing exactly the same issue right now with nginx.

Thanks

---

<div class="post-metadata">

### Author: ![mboscolo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/mboscolo/32/781_2.png) [@mboscolo](https://discuss.tryton.org/u/mboscolo)
#### Post date: [May 20, 2020, 12:40pm UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/19 "2020-05-20T12:40:38Z")

</div>

I test it in 5.4.  
I was able to make it work on firefox, but chrome give me the some behaviour

Regards,  
Matteo

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [May 21, 2020, 6:43am UTC](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605/20 "2020-05-21T06:43:47Z")

</div>

> [@mboscolo](#):
>
> but chrome give me the some behaviour

It will be great if you can explain what errors did you found on the issue.

[Next page](https://discuss.tryton.org/t/nginx-configuration-with-rewrite-does-not-shown-database-list/2605.md?page=2)
