nginx在位置中配置pgadmin

nginx在位置中配置pgadmin,nginx,pgadmin,nginx-location,nginx-reverse-proxy,Nginx,Pgadmin,Nginx Location,Nginx Reverse Proxy,请帮我写配置。 它可以工作,但当我转到location时,它会重定向到/登录,并且在/中没有位置名称 server { listen 80; server_name my.server.ru; error_log /home/user/error.log error; location / { include uwsgi_params; uwsgi_pass unix:/run/uwsgi/dj

请帮我写配置。 它可以工作,但当我转到location时,它会重定向到/登录,并且在/中没有位置名称

server {
    listen      80;
    server_name my.server.ru;
    error_log  /home/user/error.log error;
    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/run/uwsgi/django_app.sock;
    }
    location /pgadmin {

        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_pass http://127.0.0.1:5050/;
        proxy_redirect http://127.0.0.1:5050 http://$host/pgadmin/;

        }

    location /static/ {
         root    /home/user/django_app;
     expires 365d;
    }
    location /media/ {
        root /home/user/django_app;
     expires 365d;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}


}
我不知道该怎么处理它。哪里必须重写

UPD: 旋度输出

*   Trying xx.xx.xx.xx...
* TCP_NODELAY set
* Connected to my.server.ru (xx.xx.xx.xx) port 80 (#0)
> GET /pgadmin/ HTTP/1.1
> Host: my.server.ru
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-length: 0
< Location: https://my.server.ru/pgadmin/
<
* Curl_http_done: called premature == 0
* Connection #0 to host my.server.ru left intact
* Issue another request to this URL: 'https://my.server.ru/pgadmin/'
*   Trying xx.xx.xx.xx...
* TCP_NODELAY set
* Connected to my.server.ru (xx.xx.xx.xx) port 443 (#1)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=xxxxxx
*  start date: Jul 31 11:42:00 2017 GMT
*  expire date: Oct 29 11:42:00 2017 GMT
*  subjectAltName: host "my.server.ru" matched cert's "my.server.ru"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
> GET /pgadmin/ HTTP/1.1
> Host: my.server.ru
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 302 FOUND
< Server: nginx/1.10.3 (Ubuntu)
< Date: Wed, 30 Aug 2017 12:51:49 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 236
< Location: http://my.server.ru/login?next=%2F
< Set-Cookie: pga4_session="c8e21d09-5d31-42e3-a4d5-a3ed87873a69!6KcWbhziK2zypWCzKTRyFLUdszI="; Expires=Thu, 31-Aug-2017 15:51:49 GMT; HttpOnly; Path=/
<
* Ignoring the response-body
* Curl_http_done: called premature == 0
* Connection #1 to host my.server.ru left intact
* Issue another request to this URL: 'http://my.server.ru/login?next=%2F'
* Found bundle for host my.server.ru: 0x55568d6af270 [can pipeline]
* Re-using existing connection! (#0) with host my.server.ru
* Connected to my.server.ru (xx.xx.xx.xx) port 80 (#0)
> GET /login?next=%2F HTTP/1.1
> Host: my.server.ru
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-length: 0
< Location: https://my.server.ru/login?next=%2F
<
* Curl_http_done: called premature == 0
* Connection #0 to host my.server.ru left intact
* Issue another request to this URL: 'https://my.server.ru/login?next=%2F'
* Found bundle for host my.server.ru: 0x55568d6affb0 [can pipeline]
* Re-using existing connection! (#1) with host my.server.ru
* Connected to my.server.ru (xx.xx.xx.xx) port 443 (#1)
> GET /login?next=%2F HTTP/1.1
> Host: my.server.ru
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: nginx/1.10.3 (Ubuntu)
< Date: Wed, 30 Aug 2017 12:51:49 GMT
< Content-Type: text/html
< Content-Length: 79
< X-Frame-Options: SAMEORIGIN
<
* Curl_http_done: called premature == 0
* Connection #1 to host my.server.ru left intact
*正在尝试xx.xx.xx.xx。。。
*TCP_节点集
*已连接到my.server.ru(xx.xx.xx.xx)端口80(#0)
>GET/pgadmin/HTTP/1.1
>主机:my.server.ru
>用户代理:curl/7.52.1
>接受:*/*
>
GET/pgadmin/HTTP/1.1
>主机:my.server.ru
>用户代理:curl/7.52.1
>接受:*/*
>
找到获取/登录?下一步=%2F HTTP/1.1
>主机:my.server.ru
>用户代理:curl/7.52.1
>接受:*/*
>
获取/登录?下一步=%2F HTTP/1.1
>主机:my.server.ru
>用户代理:curl/7.52.1
>接受:*/*
>
未找到
未找到在此服务器上未找到请求的URL/登录名


我们在这里看到重定向到/

我找到了另一个好方法-通过ssh隧道运行。希望它能帮助别人。

我最终得到了以下配置:

location /pgadmin {
    proxy_pass http://pgadmin:80;
    proxy_redirect http:// $scheme://;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Script-Name /pgadmin;
}

这里最重要的是
X-Script-Name
,指定用于在前端构建超链接的路径前缀。还需要
proxy\u redirect
指令来修复浏览器中的混合内容警告。

使用下面的Nginx config为PGAdmin创建反向代理

vi /etc/nginx/nginx.conf

location /service/pg/ {
    rewrite ^(.+)/service/pg/(.*)$ $1/$2;
    proxy_read_timeout 300;
    proxy_pass http://localhost:7003/; 
    proxy_redirect http://localhost:7003/ https://$host/service/pg/;
    proxy_set_header Accept-Encoding "";
    sub_filter "/service/pg" "";
    sub_filter '"/static/' '"/service/pg/static/';
    sub_filter "'/static/" "'/service/pg/static/";
    sub_filter '="/login' '="/service/pg/login';
    sub_filter '/browser/' '/service/pg/browser/';
    sub_filter '/tools/' '/service/pg/tools/';
    sub_filter '/settings/' '/service/pg/settings/';
    sub_filter '/misc/' '/service/pg/misc/';
    sub_filter '/preferences/' '/service/pg/preferences/';
    sub_filter '/dashboard/' '/service/pg/dashboard/';
    sub_filter '/user_management/' '/service/pg/user_management/';
    sub_filter '/favicon.ico' '/service/pg/favicon.ico';
    sub_filter '/datagrid/' '/service/pg/datagrid/';
    sub_filter '/sqleditor/' '/service/pg/sqleditor/';
    sub_filter_types "*";
    sub_filter_once off;
    sub_filter_last_modified off;
}

更改代理服务器重定向http://127.0.0.1:5050 http://$host/pgadmin/
代理\u重定向http://127.0.0.1:5050/ http://$host/pgadmin/。也可对
curl-vL进行后期输出http://my.server.ru/pgadmin/
已将Chenes发布到配置。完成了,但我重定向到了根页面。好吧,看来你有更多的配置,你发布的配置只是其中的一部分。您的问题是,您正在定义的块位于listen 80中,但是还有一个重定向到https的块,并且https块没有
/pgadmin
。所以你得到了一个https重定向,然后
/pgadmin
不在那里,所以你得到了一个
登录
重定向否我刚刚添加了代理重定向http https;到我的配置。它的包,我想我应该退出重定向线程。我认为最好的办法是在这种情况下做子域?不确定,看看对你有用吗