server {
listen <address>: 443;
server_name hg1.whatever.com;
access_log /var/log/nginx/hg1.access.log;
error_log /var/log/nginx/hg2.error.log;
ssl on;
ssl_protocols SSLv3 TLSv1;
ssl_certificate /etc/nginx/ssl/hg/hgmaincert.pem;
ssl_certificate_key /etc/nginx/ssl/hg/hgmaincert.key;
location / {
fastcgi_pass unix: /var/run/hgwebdir.fcgi.socket;
fastcgi_param PATH_INFO $ fastcgi_script_name;
fastcgi_param QUERY_STRING $ query_string;
fastcgi_param REQUEST_METHOD $ request_method;
fastcgi_param CONTENT_TYPE $ content_type;
fastcgi_param CONTENT_LENGTH $ content_length;
fastcgi_param SERVER_PROTOCOL $ server_protocol;
fastcgi_param SERVER_PORT $ server_port;
fastcgi_param SERVER_NAME $ server_name;
}
}
#!/usr/bin/python2.6
from mercurial import demandimport; demandimport . enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
from mercurial.hgweb.request import wsgiapplication
from flup.server.fcgi import WSGIServer
def make_web_app ():
return hgwebdir( "path_to/hgweb.config" )
WSGIServer(wsgiapplication(make_web_app)) . run()
server_name hg1.whatever.com;
server_name hg2.whatever.com;
server_name hg3.whatever.com;
from mercurial.hgweb.hgwebdir_mod import hgwebdir
class hgtreewebdir (hgwebdir):
refreshinterval = 0 # = 0, !
def __init__ ( self , conf, baseui = None , virtuals = {}):
self . baseconf = conf
self . virtuals = virtuals
hgwebdir . __init__( self , conf, baseui)
def run_wsgi ( self , req):
if self . virtuals != {}:
virtual = req . env . get( "HTTP_HOST" , "" )
if virtual in self . virtuals:
self . conf = self . virtuals[virtual]
return hgwebdir . run_wsgi( self , req)
self . conf = self . baseconf
return hgwebdir . run_wsgi( self , req)
#!/usr/bin/python2.6
from mercurial import demandimport; demandimport . enable()
from hgtreewebdir_mod import hgtreewebdir
from mercurial.hgweb.request import wsgiapplication
from flup.server.fcgi import WSGIServer
def make_web_app ():
return hgtreewebdir( "path_to_configs/mainhgweb.config" ,
virtuals = {
"hg2.whatever.com" : "path_to_configs/hg2hgweb.config" ,
"hg3.whatever.com" : "path_to_configs/hg3hgweb.config"
})
WSGIServer(wsgiapplication(make_web_app)) . run()
Source: https://habr.com/ru/post/84191/
All Articles