Skip to content

Instantly share code, notes, and snippets.

@cato-
Last active March 6, 2018 19:28
Show Gist options
  • Save cato-/30c50e8ea579800c3f40beaf4cf1af60 to your computer and use it in GitHub Desktop.
Save cato-/30c50e8ea579800c3f40beaf4cf1af60 to your computer and use it in GitHub Desktop.
Install pypiserver
server {
server_name build.example.com;
listen 10.10.10.10:443;
ssl_certificate /etc/nginx/ssl/build.example.com.crt;
ssl_certificate_key /etc/nginx/ssl/build.example.com.key;
location /pypi {
proxy_pass http://127.0.0.1:4046;
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-Proto $scheme;
}
}
server {
listen 10.10.10.10:80;
server_name build.example.com;
include /etc/nginx/snippets/letsencrypt.conf;
location / {
return 301 https://$host$request_uri;
}
}
[uwsgi]
plugin = python,http
http-socket = 127.0.0.1:4046
wsgi-file = /srv/build/pypiserver_wsgi.py
callable = wsgi_app
pyargv = /srv/build/python_packages
master = True
processes = 1
threads = 2
lazy-app = True
virtualenv = /srv/build/venv-site/
from pypiserver import app, bottle
import sys
child_app = app(
root=sys.argv[1],
hash_algo=None,
redirect_to_fallback=False,
password_file='/etc/nginx/user/backend',
fallback_url=False,
authenticated=['list', 'download', 'update'],
cache_control=20
)
wsgi_app = bottle.Bottle()
# /pypi/ is the subdirectory where pypiserver is served
wsgi_app.mount('/pypi/', child_app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment