Обсуждение: [pgadmin-support] pgadmin4 running behind nginx

Поиск
Список
Период
Сортировка

[pgadmin-support] pgadmin4 running behind nginx

От
jbiskofski
Дата:
Hello everyone, 

I have installed pgadmin4 on apache 2.2 with mod_wsgi, and it seems to be working correctly. 

The problem is I need to run nginx in front of it to enable https and caching. When I try to access pgadmin with this setup I get errors in the browser about some elements not being able to be loaded because they are linked through http instead of https.

login:1 Mixed Content: The page at 'https://REMOVED-BY-ME/login?next=/browser/browser.css' was loaded over HTTPS, but requested an insecure stylesheet 'http://REMOVED-BY-ME/login?next=%2Fbrowser%2Fbrowser.css'. This request has been blocked; the content must be served over HTTPS.

This is OK at the login page, but once I login, I get the eternal pgadmin is loading screen and a lot more of these same errors in my browser console.

My question is, how can I tell pgadmin4 what its base URL is ?

Thank you.


Re: [pgadmin-support] pgadmin4 running behind nginx

От
Dave Page
Дата:
Hi

On Sun, Jan 29, 2017 at 7:33 PM, jbiskofski <jbiskofski@gmail.com> wrote:
> Hello everyone,
>
> I have installed pgadmin4 on apache 2.2 with mod_wsgi, and it seems to be
> working correctly.
>
> The problem is I need to run nginx in front of it to enable https and
> caching. When I try to access pgadmin with this setup I get errors in the
> browser about some elements not being able to be loaded because they are
> linked through http instead of https.
>
> login:1 Mixed Content: The page at
> 'https://REMOVED-BY-ME/login?next=/browser/browser.css' was loaded over
> HTTPS, but requested an insecure stylesheet
> 'http://REMOVED-BY-ME/login?next=%2Fbrowser%2Fbrowser.css'. This request has
> been blocked; the content must be served over HTTPS.

Harshal, can you take a look at this please? I can see my browser
loading http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css, but
I cannot see why. I must be overlooking something.

> This is OK at the login page, but once I login, I get the eternal pgadmin is
> loading screen and a lot more of these same errors in my browser console.
>
> My question is, how can I tell pgadmin4 what its base URL is ?

You can tell it the directory root (though you shouldn't need to), but
I know of no way to give it the base URL. Normally it figures it out
itself - but then normally we also wouldn't put Apache behind Nginx,
but just setup SSL directly on Apache.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: [pgadmin-support] pgadmin4 running behind nginx

От
Harshal Dhumal
Дата:


-- 
Harshal Dhumal
Software Engineer

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Mon, Jan 30, 2017 at 3:33 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi

On Sun, Jan 29, 2017 at 7:33 PM, jbiskofski <jbiskofski@gmail.com> wrote:
> Hello everyone,
>
> I have installed pgadmin4 on apache 2.2 with mod_wsgi, and it seems to be
> working correctly.
>
> The problem is I need to run nginx in front of it to enable https and
> caching. When I try to access pgadmin with this setup I get errors in the
> browser about some elements not being able to be loaded because they are
> linked through http instead of https.
>
> login:1 Mixed Content: The page at
> 'https://REMOVED-BY-ME/login?next=/browser/browser.css' was loaded over
> HTTPS, but requested an insecure stylesheet
> 'http://REMOVED-BY-ME/login?next=%2Fbrowser%2Fbrowser.css'. This request has
> been blocked; the content must be served over HTTPS.

Harshal, can you take a look at this please? I can see my browser
loading http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css, but
I cannot see why. I must be overlooking something.

Yes sure I'll look in to this.
 
> This is OK at the login page, but once I login, I get the eternal pgadmin is
> loading screen and a lot more of these same errors in my browser console.
>
> My question is, how can I tell pgadmin4 what its base URL is ?

You can tell it the directory root (though you shouldn't need to), but
I know of no way to give it the base URL. Normally it figures it out
itself - but then normally we also wouldn't put Apache behind Nginx,
but just setup SSL directly on Apache.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: [pgadmin-support] pgadmin4 running behind nginx

От
Harshal Dhumal
Дата:
Hi,

When I setup my machine with below server setup and without proxy_redirect I got slightly different behaviour. In my case all redirects were failing cause browser was redirecting all request to http while server (nginx) was configure to serve only https. I didn't get any intermittent state like pgAdmin4 front page was loading but other requests (like css, js) was failing.

Issue was when pgAdmin4 app returns redirect (301 /302) response to apache and apache to nginx; the nginx was returning redirect location header as is (i.e. with http protocol as apache was configured to accept only http)

To avoid this I need to rewrite location header at nginx (proxy_redirect) before sending it to browser.
        
        proxy_set_header X-Real-IP  $remote_addr; 
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:81;
        proxy_redirect http:// https://;

With above nginx configuration pgAdmin was loading properly.

Server setup:

Nginx listing at 443 (https only) and forwarding all requests to apache at 127.0.0.1:81
Apache listing at port 81 (http only) with pgAdmin4 wsgi



-- 
Harshal Dhumal
Software Engineer

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Mon, Jan 30, 2017 at 4:44 PM, Harshal Dhumal <harshal.dhumal@enterprisedb.com> wrote:


-- 
Harshal Dhumal
Software Engineer

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Mon, Jan 30, 2017 at 3:33 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi

On Sun, Jan 29, 2017 at 7:33 PM, jbiskofski <jbiskofski@gmail.com> wrote:
> Hello everyone,
>
> I have installed pgadmin4 on apache 2.2 with mod_wsgi, and it seems to be
> working correctly.
>
> The problem is I need to run nginx in front of it to enable https and
> caching. When I try to access pgadmin with this setup I get errors in the
> browser about some elements not being able to be loaded because they are
> linked through http instead of https.
>
> login:1 Mixed Content: The page at
> 'https://REMOVED-BY-ME/login?next=/browser/browser.css' was loaded over
> HTTPS, but requested an insecure stylesheet
> 'http://REMOVED-BY-ME/login?next=%2Fbrowser%2Fbrowser.css'. This request has
> been blocked; the content must be served over HTTPS.

Harshal, can you take a look at this please? I can see my browser
loading http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css, but
I cannot see why. I must be overlooking something.

Yes sure I'll look in to this.
 
> This is OK at the login page, but once I login, I get the eternal pgadmin is
> loading screen and a lot more of these same errors in my browser console.
>
> My question is, how can I tell pgadmin4 what its base URL is ?

You can tell it the directory root (though you shouldn't need to), but
I know of no way to give it the base URL. Normally it figures it out
itself - but then normally we also wouldn't put Apache behind Nginx,
but just setup SSL directly on Apache.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: [pgadmin-support] pgadmin4 running behind nginx

От
Dave Page
Дата:
On Wed, Feb 1, 2017 at 10:11 AM, Harshal Dhumal
<harshal.dhumal@enterprisedb.com> wrote:
> Hi,
>
> When I setup my machine with below server setup and without proxy_redirect I
> got slightly different behaviour. In my case all redirects were failing
> cause browser was redirecting all request to http while server (nginx) was
> configure to serve only https. I didn't get any intermittent state like
> pgAdmin4 front page was loading but other requests (like css, js) was
> failing.
>
> Issue was when pgAdmin4 app returns redirect (301 /302) response to apache
> and apache to nginx; the nginx was returning redirect location header as is
> (i.e. with http protocol as apache was configured to accept only http)
>
> To avoid this I need to rewrite location header at nginx (proxy_redirect)
> before sending it to browser.
>
>         proxy_set_header X-Real-IP  $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header Host $host;
>         proxy_pass http://127.0.0.1:81;
>         proxy_redirect http:// https://;
>
> With above nginx configuration pgAdmin was loading properly.
>
> Server setup:
>
> Nginx listing at 443 (https only) and forwarding all requests to apache at
> 127.0.0.1:81
> Apache listing at port 81 (http only) with pgAdmin4 wsgi

Nice - thanks Harshal.

Were you able to see why we're trying to load
http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css ? I can
reproduce that just by pointing my browser at a dev server (e.g.
werkzeug). No Apache or nginx needed.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: [pgadmin-support] pgadmin4 running behind nginx

От
Ashesh Vashi
Дата:
On Wed, Feb 1, 2017 at 3:44 PM, Dave Page <dpage@pgadmin.org> wrote:
On Wed, Feb 1, 2017 at 10:11 AM, Harshal Dhumal
<harshal.dhumal@enterprisedb.com> wrote:
> Hi,
>
> When I setup my machine with below server setup and without proxy_redirect I
> got slightly different behaviour. In my case all redirects were failing
> cause browser was redirecting all request to http while server (nginx) was
> configure to serve only https. I didn't get any intermittent state like
> pgAdmin4 front page was loading but other requests (like css, js) was
> failing.
>
> Issue was when pgAdmin4 app returns redirect (301 /302) response to apache
> and apache to nginx; the nginx was returning redirect location header as is
> (i.e. with http protocol as apache was configured to accept only http)
>
> To avoid this I need to rewrite location header at nginx (proxy_redirect)
> before sending it to browser.
>
>         proxy_set_header X-Real-IP  $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header Host $host;
>         proxy_pass http://127.0.0.1:81;
>         proxy_redirect http:// https://;
>
> With above nginx configuration pgAdmin was loading properly.
>
> Server setup:
>
> Nginx listing at 443 (https only) and forwarding all requests to apache at
> 127.0.0.1:81
> Apache listing at port 81 (http only) with pgAdmin4 wsgi

Nice - thanks Harshal.

Were you able to see why we're trying to load
http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css ? I can
reproduce that just by pointing my browser at a dev server (e.g.
werkzeug). No Apache or nginx needed.
I think - I spotted it.

We've the 'login_required' decorated for the browser_css function.
And, It has been referred in base.html template, which is also used in the login.html.

Please try to remove '@login_required' decorator from the 'browser_css' function, found in the 'web/pgadmin/browser/__init__.py' file.


--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


--
Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support

Re: [pgadmin-support] pgadmin4 running behind nginx

От
Dave Page
Дата:


On Wed, Feb 1, 2017 at 10:20 AM, Ashesh Vashi <ashesh.vashi@enterprisedb.com> wrote:
On Wed, Feb 1, 2017 at 3:44 PM, Dave Page <dpage@pgadmin.org> wrote:
On Wed, Feb 1, 2017 at 10:11 AM, Harshal Dhumal
<harshal.dhumal@enterprisedb.com> wrote:
> Hi,
>
> When I setup my machine with below server setup and without proxy_redirect I
> got slightly different behaviour. In my case all redirects were failing
> cause browser was redirecting all request to http while server (nginx) was
> configure to serve only https. I didn't get any intermittent state like
> pgAdmin4 front page was loading but other requests (like css, js) was
> failing.
>
> Issue was when pgAdmin4 app returns redirect (301 /302) response to apache
> and apache to nginx; the nginx was returning redirect location header as is
> (i.e. with http protocol as apache was configured to accept only http)
>
> To avoid this I need to rewrite location header at nginx (proxy_redirect)
> before sending it to browser.
>
>         proxy_set_header X-Real-IP  $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header Host $host;
>         proxy_pass http://127.0.0.1:81;
>         proxy_redirect http:// https://;
>
> With above nginx configuration pgAdmin was loading properly.
>
> Server setup:
>
> Nginx listing at 443 (https only) and forwarding all requests to apache at
> 127.0.0.1:81
> Apache listing at port 81 (http only) with pgAdmin4 wsgi

Nice - thanks Harshal.

Were you able to see why we're trying to load
http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css ? I can
reproduce that just by pointing my browser at a dev server (e.g.
werkzeug). No Apache or nginx needed.
I think - I spotted it.

We've the 'login_required' decorated for the browser_css function.
And, It has been referred in base.html template, which is also used in the login.html.

Please try to remove '@login_required' decorator from the 'browser_css' function, found in the 'web/pgadmin/browser/__init__.py' file.

Good shout - that fixes that problem, but leaves us with an http/500 error because browser_css loads per-user preferences. I think we need to conditionally include this block from base.html:
<!-- View specified stylesheets -->
{% for stylesheet in current_app.stylesheets %}
<link type="text/css" rel="stylesheet" href="{{ stylesheet }}">
{% endfor %}

But I don't have time to investigate further right now as I have to leave for FOSDEM soon.
 
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: [pgadmin-support] pgadmin4 running behind nginx

От
jbiskofski
Дата:
I Set up my nginx as Harshal suggested and this fixed the problem. Thanks for the help! 

On Wed, Feb 1, 2017 at 3:37 AM, Dave Page <dpage@pgadmin.org> wrote:


On Wed, Feb 1, 2017 at 10:20 AM, Ashesh Vashi <ashesh.vashi@enterprisedb.com> wrote:
On Wed, Feb 1, 2017 at 3:44 PM, Dave Page <dpage@pgadmin.org> wrote:
On Wed, Feb 1, 2017 at 10:11 AM, Harshal Dhumal
<harshal.dhumal@enterprisedb.com> wrote:
> Hi,
>
> When I setup my machine with below server setup and without proxy_redirect I
> got slightly different behaviour. In my case all redirects were failing
> cause browser was redirecting all request to http while server (nginx) was
> configure to serve only https. I didn't get any intermittent state like
> pgAdmin4 front page was loading but other requests (like css, js) was
> failing.
>
> Issue was when pgAdmin4 app returns redirect (301 /302) response to apache
> and apache to nginx; the nginx was returning redirect location header as is
> (i.e. with http protocol as apache was configured to accept only http)
>
> To avoid this I need to rewrite location header at nginx (proxy_redirect)
> before sending it to browser.
>
>         proxy_set_header X-Real-IP  $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header Host $host;
>         proxy_pass http://127.0.0.1:81;
>         proxy_redirect http:// https://;
>
> With above nginx configuration pgAdmin was loading properly.
>
> Server setup:
>
> Nginx listing at 443 (https only) and forwarding all requests to apache at
> 127.0.0.1:81
> Apache listing at port 81 (http only) with pgAdmin4 wsgi

Nice - thanks Harshal.

Were you able to see why we're trying to load
http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css ? I can
reproduce that just by pointing my browser at a dev server (e.g.
werkzeug). No Apache or nginx needed.
I think - I spotted it.

We've the 'login_required' decorated for the browser_css function.
And, It has been referred in base.html template, which is also used in the login.html.

Please try to remove '@login_required' decorator from the 'browser_css' function, found in the 'web/pgadmin/browser/__init__.py' file.

Good shout - that fixes that problem, but leaves us with an http/500 error because browser_css loads per-user preferences. I think we need to conditionally include this block from base.html:
<!-- View specified stylesheets -->
{% for stylesheet in current_app.stylesheets %}
<link type="text/css" rel="stylesheet" href="{{ stylesheet }}">
{% endfor %}

But I don't have time to investigate further right now as I have to leave for FOSDEM soon.
 
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: [pgadmin-support] pgadmin4 running behind nginx

От
Dan Davis
Дата:
Another trick here is to let the back-end know that it is https:

proxy_set_header X-Forwarded-Proto https;


On Wed, Feb 1, 2017 at 12:34 PM, jbiskofski <jbiskofski@gmail.com> wrote:
I Set up my nginx as Harshal suggested and this fixed the problem. Thanks for the help! 

On Wed, Feb 1, 2017 at 3:37 AM, Dave Page <dpage@pgadmin.org> wrote:


On Wed, Feb 1, 2017 at 10:20 AM, Ashesh Vashi <ashesh.vashi@enterprisedb.com> wrote:
On Wed, Feb 1, 2017 at 3:44 PM, Dave Page <dpage@pgadmin.org> wrote:
On Wed, Feb 1, 2017 at 10:11 AM, Harshal Dhumal
<harshal.dhumal@enterprisedb.com> wrote:
> Hi,
>
> When I setup my machine with below server setup and without proxy_redirect I
> got slightly different behaviour. In my case all redirects were failing
> cause browser was redirecting all request to http while server (nginx) was
> configure to serve only https. I didn't get any intermittent state like
> pgAdmin4 front page was loading but other requests (like css, js) was
> failing.
>
> Issue was when pgAdmin4 app returns redirect (301 /302) response to apache
> and apache to nginx; the nginx was returning redirect location header as is
> (i.e. with http protocol as apache was configured to accept only http)
>
> To avoid this I need to rewrite location header at nginx (proxy_redirect)
> before sending it to browser.
>
>         proxy_set_header X-Real-IP  $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header Host $host;
>         proxy_pass http://127.0.0.1:81;
>         proxy_redirect http:// https://;
>
> With above nginx configuration pgAdmin was loading properly.
>
> Server setup:
>
> Nginx listing at 443 (https only) and forwarding all requests to apache at
> 127.0.0.1:81
> Apache listing at port 81 (http only) with pgAdmin4 wsgi

Nice - thanks Harshal.

Were you able to see why we're trying to load
http://127.0.0.1:5050/login?next=%2Fbrowser%2Fbrowser.css ? I can
reproduce that just by pointing my browser at a dev server (e.g.
werkzeug). No Apache or nginx needed.
I think - I spotted it.

We've the 'login_required' decorated for the browser_css function.
And, It has been referred in base.html template, which is also used in the login.html.

Please try to remove '@login_required' decorator from the 'browser_css' function, found in the 'web/pgadmin/browser/__init__.py' file.

Good shout - that fixes that problem, but leaves us with an http/500 error because browser_css loads per-user preferences. I think we need to conditionally include this block from base.html:
<!-- View specified stylesheets -->
{% for stylesheet in current_app.stylesheets %}
<link type="text/css" rel="stylesheet" href="{{ stylesheet }}">
{% endfor %}

But I don't have time to investigate further right now as I have to leave for FOSDEM soon.
 
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: pgadmin4 running behind nginx

От
rhuddbiz
Дата:
how can i specify a path for the python application behind nginx ?  we want
to enable security with our existing ssl cert .  we have https://foo.com/
and we want to forward https://foo.com/pgadmin/ to our python wrapper around
pgadmin4.  unfortunately, the naive approach does not work as the href links
all appear to be  absolute on the login page.  i'm hoping for a simple env
variable.  



--
View this message in context: http://www.postgresql-archive.org/pgadmin4-running-behind-nginx-tp5941547p5953622.html
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.



Re: pgadmin4 running behind nginx

От
Dave Page
Дата:
On Sun, Apr 2, 2017 at 9:00 PM, rhuddbiz <rhuddbiz@gmail.com> wrote:
> how can i specify a path for the python application behind nginx ?  we want
> to enable security with our existing ssl cert .  we have https://foo.com/
> and we want to forward https://foo.com/pgadmin/ to our python wrapper around
> pgadmin4.  unfortunately, the naive approach does not work as the href links
> all appear to be  absolute on the login page.  i'm hoping for a simple env
> variable.

With Apache I just do something like the following, and it just works
(the underlying Flask framework figures out the path prefix
automatically):
   WSGIDaemonProcess pgadmin processes=1 threads=25   WSGIScriptAlias /pgadmin4 /opt/pgAdmin4/web/pgAdmin4.wsgi
   <Directory /opt/pgAdmin4/web>       WSGIProcessGroup pgadmin       WSGIApplicationGroup %{GLOBAL}       Require all
granted  </Directory>
 

I'm afraid I don't know nginx well enough to suggest specifics for that server.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: pgadmin4 running behind nginx

От
rhuddbiz
Дата:
i don't think knowing nginx is the key to this.  it's more of a general
question for any proxy setup that uses python to run pgadmin4.  we are
launching pgadmin4 on localhost:5050, with a systemd file containing
/usr/bin/python3.5
/usr/local/lib/python3.5/dist-packages/pgadmin4/pgAdmin4.py

is there a magical incantation to get a param or env variable to python to
get the  Flask framework to put a path in front of the root pgadmin app ? 
right now, the pgadmin4 app is available at http://localhost:5050, need it
to be at http://localhost:5050/pgadmin/ .  whatever solution is found will
be relevant to all non-apache proxy servers, so getting it out on the
mailing list / internet would be helpful :)

i guess another path would be to setup a uwsgi  server in the systemd file,
and use ngx_http_uwsgi_module for proxying.  but that won't be a generic
solution for other proxy servers. 



--
View this message in context: http://www.postgresql-archive.org/pgadmin4-running-behind-nginx-tp5941547p5953727.html
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.



Re: pgadmin4 running behind nginx

От
Dave Page
Дата:
On Mon, Apr 3, 2017 at 2:30 PM, rhuddbiz <rhuddbiz@gmail.com> wrote:
> i don't think knowing nginx is the key to this.  it's more of a general
> question for any proxy setup that uses python to run pgadmin4.  we are
> launching pgadmin4 on localhost:5050, with a systemd file containing
> /usr/bin/python3.5
> /usr/local/lib/python3.5/dist-packages/pgadmin4/pgAdmin4.py
>
> is there a magical incantation to get a param or env variable to python to
> get the  Flask framework to put a path in front of the root pgadmin app ?
> right now, the pgadmin4 app is available at http://localhost:5050, need it
> to be at http://localhost:5050/pgadmin/ .  whatever solution is found will
> be relevant to all non-apache proxy servers, so getting it out on the
> mailing list / internet would be helpful :)
>
> i guess another path would be to setup a uwsgi  server in the systemd file,
> and use ngx_http_uwsgi_module for proxying.  but that won't be a generic
> solution for other proxy servers.

If it won't figure it out automatically as it does with Apache, you
could try forcing it by adding:

APPLICATION_ROOT='/foo/bar/whizz'

to your config_local.py (create one alongside config.py if needed).

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: pgadmin4 running behind nginx

От
rhuddbiz
Дата:
well, setting APPLICATION_ROOT did not work. i know i have the
config_local.py setup correctly because i am able to configure
DEFAULT_SERVER. i think i see where you came up with APPLICATION_ROOT param,
http://flask.pocoo.org/docs/0.12/config/.  unfortunately, it looks like
pgAdmin4.py does not make use of / pass that param.  this appears to be the
relevant content of pgAdmin4.py that would include that param.
app.run(           host=config.DEFAULT_SERVER,           port=server_port,           use_reloader=((not
PGADMIN_RUNTIME)and app.debug),           threaded=config.THREADED_MODE       )
 
. so i guess the default pgAdmin4.py is a no go .  i'll have to go through
the process of setting up a uWSGI server. 



--
View this message in context: http://www.postgresql-archive.org/pgadmin4-running-behind-nginx-tp5941547p5953892.html
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.



Re: pgadmin4 running behind nginx

От
Dave Page
Дата:
On Tue, Apr 4, 2017 at 12:19 AM, rhuddbiz <rhuddbiz@gmail.com> wrote:
> well, setting APPLICATION_ROOT did not work. i know i have the
> config_local.py setup correctly because i am able to configure
> DEFAULT_SERVER. i think i see where you came up with APPLICATION_ROOT param,
> http://flask.pocoo.org/docs/0.12/config/.  unfortunately, it looks like
> pgAdmin4.py does not make use of / pass that param.  this appears to be the
> relevant content of pgAdmin4.py that would include that param.
> app.run(
>             host=config.DEFAULT_SERVER,
>             port=server_port,
>             use_reloader=((not PGADMIN_RUNTIME) and app.debug),
>             threaded=config.THREADED_MODE
>         )
> . so i guess the default pgAdmin4.py is a no go .  i'll have to go through
> the process of setting up a uWSGI server.

Flask has access to the entire config (it'll ignore the pgAdmin
specific parts). This is handled in web/pgadmin/__init__.py, around
line 144:

app.config.from_object(config)
app.config.update(dict(PROPAGATE_EXCEPTIONS=True))

I don't know why it's ignoring it - but as I said upthread, I've never
had to use it. It just works with Apache HTTPD (as intended).

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: pgadmin4 running behind nginx

От
jbiskofski
Дата:
this is how I got it to work :

VHOST FILE
==========

server {

listen *:443 ssl;

server_name  pg.YOURDOMAIN.com;

include /usr/local/nginx/conf/ssl.conf;

include /usr/local/nginx/conf/proxies.conf;


location / {

         proxy_pass       http://pgadmin-backend;

         proxy_next_upstream error timeout http_500 http_502;

         proxy_set_header X-Real-IP  $remote_addr; 

         proxy_set_header X-Forwarded-For $remote_addr;

         proxy_set_header Host $host;

         proxy_redirect   http:// https://;

}

}


IN ANOTHER FILE ( in my case its called backends.conf )

============================================

upstream pgadmin-backend {

        server 127.0.0.1:8080;

        server 127.0.0.1:8080 backup;

        server 127.0.0.1:8080 backup;

        server 127.0.0.1:8080 backup;

}


=========================================

I dont know why but pgadmin sometimes fails in retrieving static content ( css, js, etc ) that it serves from python somehow. If one of these files fails to load the whole application becomes unresponsive. 

I basically set it up so if it failes it retries again 3 times ( thats why I have 127.0.0.1 as a backup backend 3 times ). I know its ugly and its hacky, but it works. 


Hope this helps.


- Jose



On Tue, Apr 4, 2017 at 1:44 AM, Dave Page <dpage@pgadmin.org> wrote:
On Tue, Apr 4, 2017 at 12:19 AM, rhuddbiz <rhuddbiz@gmail.com> wrote:
> well, setting APPLICATION_ROOT did not work. i know i have the
> config_local.py setup correctly because i am able to configure
> DEFAULT_SERVER. i think i see where you came up with APPLICATION_ROOT param,
> http://flask.pocoo.org/docs/0.12/config/.  unfortunately, it looks like
> pgAdmin4.py does not make use of / pass that param.  this appears to be the
> relevant content of pgAdmin4.py that would include that param.
> app.run(
>             host=config.DEFAULT_SERVER,
>             port=server_port,
>             use_reloader=((not PGADMIN_RUNTIME) and app.debug),
>             threaded=config.THREADED_MODE
>         )
> . so i guess the default pgAdmin4.py is a no go .  i'll have to go through
> the process of setting up a uWSGI server.

Flask has access to the entire config (it'll ignore the pgAdmin
specific parts). This is handled in web/pgadmin/__init__.py, around
line 144:

app.config.from_object(config)
app.config.update(dict(PROPAGATE_EXCEPTIONS=True))

I don't know why it's ignoring it - but as I said upthread, I've never
had to use it. It just works with Apache HTTPD (as intended).

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


--
Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support

Re: pgadmin4 running behind nginx

От
rhuddbiz
Дата:
Dave,

after installing 
https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.3/pip/pgadmin4-1.3-py2.py3-none-any.whl

i can't seem to find any filename matching the one you mentioned, that seems
strange to me.
web/pgadmin/__init__.py



--
View this message in context: http://www.postgresql-archive.org/pgadmin4-running-behind-nginx-tp5941547p5954155.html
Sent from the PostgreSQL - pgadmin support mailing list archive at Nabble.com.



Re: pgadmin4 running behind nginx

От
Dave Page
Дата:
On Tue, Apr 4, 2017 at 11:36 PM, rhuddbiz <rhuddbiz@gmail.com> wrote:
> Dave,
>
> after installing
> https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.3/pip/pgadmin4-1.3-py2.py3-none-any.whl
>
> i can't seem to find any filename matching the one you mentioned, that seems
> strange to me.
> web/pgadmin/__init__.py

That's the path in a source checkout and in most packages. If you've
installed the wheel though, the web/ part is removed as the wheel
doesn't include other parts like the runtime. For example, on my
system in a virtual environment called test, the path is:

~/.virtualenvs/test/lib/python2.7/site-packages/pgadmin4/pgadmin/__init__.py


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company