Skip to content

Instantly share code, notes, and snippets.

@Zash
Last active July 19, 2020 10:27
Show Gist options
  • Save Zash/8eac4352b320aebe6e4c204fd58b5c0e to your computer and use it in GitHub Desktop.
Save Zash/8eac4352b320aebe6e4c204fd58b5c0e to your computer and use it in GitHub Desktop.
hgweb+nginx
server {
server_name hg.example.com;
root /var/www/hg.example.com;
listen 0.0.0.0:80;
listen 0.0.0.0:443 ssl;
listen [::]:80;
listen [::]:443 ssl http2;
access_log /var/log/nginx/hg.example.com-access.log;
location /static {
alias /usr/lib/python2.7/dist-packages/mercurial/templates/static;
expires 30d;
}
location / {
try_files $uri @hgweb_fastcgi;
}
location @hgweb_fastcgi {
# See /etc/systemd/system/hgweb.service and .socket
fastcgi_pass unix:/run/hgweb.sock;
fastcgi_buffering on;
# fastcgi_cache CGI;
# expires 1m;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/hgweb.cgi;
}
}
#!/usr/bin/env python
#
# An example FastCGI script for use with flup, edit as necessary
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/etc/hgweb.conf"
# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")
# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
from flup.server.fcgi import WSGIServer
application = hgweb(config)
WSGIServer(application).run()
[Unit]
Description=Hgweb Fastcgi
Requisite=nginx.service
AssertPathExists=/var/www/hg.example.com
[Service]
Type=simple
User=www-data
Group=www-data
ExecStart=/var/www/hg.example.com/hgweb.fcgi
WorkingDirectory=/
Nice=10
StandardInput=socket
StandardOutput=journal
StandardError=journal
[Unit]
Description=Hgweb Socket
[Install]
WantedBy=sockets.target
[Socket]
SocketUser=www-data
SocketGroup=www-data
SocketMode=0600
ListenStream=/run/hgweb.sock
Accept=false
Service=hgweb.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment