I'm trying to get a custom PyPI server running using pypiserver.
I tried to modify the example nginx.conf file in the README in order to use /mylocation instead of / and ended up with the following:
server {
server_name mypi.com;
listen 443 ssl;
ssl_certificate /cert/path;
ssl_certificate_key /key/path;
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location /mylocation {
auth_basic "Howdy!";
auth_basic_user_file /path/to/pwd;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass 127.0.0.1:8080/;
}
}
If I connect directly (via browser) to http://mypi.com:8080, the default welcome page of pypiserver pops up. If I try instead to connecto to https://mypi.com/mylocation it redirects me to https://mypi.com/simple/ and throws a 404 error. I thought that the combination of location + proxy_pass was basically a way of saying "Connecting to mypi.com/mylocation is the same as mypi.com:8080/". Did I get this wrong? Or is the problem related to pypiserver itself?
If it helps, I'm on a Raspberry Pi with the following programs' versions:
- nginx: 1.12.2
- pypiserver: 1.2.1
- python: 3.6.5
A location block with
proxy_passjust passes through the path unchanged unless yourewriteit.For your case add the following rewrite rule after the
proxy_passstatement.rewrite ^/mylocation/?(.*)$ /$1 break;