diff options
| author | Luke Hoersten <[email protected]> | 2020-06-29 18:38:49 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2020-06-29 18:38:49 -0500 |
| commit | 993697be3753be25f3d05617c53d66c64b0e97b5 (patch) | |
| tree | 41cb6f26f121f0659be66269110624bd21a3cf63 /mercurial/web | |
| parent | b4c42a383953a34d6ff8091caf6e6bd34776b0c6 (diff) | |
Added mercurial web hosting
Diffstat (limited to 'mercurial/web')
| -rw-r--r-- | mercurial/web/handlers/main.yaml | 5 | ||||
| -rw-r--r-- | mercurial/web/tasks/main.yaml | 38 | ||||
| -rw-r--r-- | mercurial/web/templates/hgweb.config.j2 | 6 | ||||
| -rw-r--r-- | mercurial/web/templates/hgweb.ini.j2 | 8 | ||||
| -rw-r--r-- | mercurial/web/templates/hgweb.nginx.conf.j2 | 33 | ||||
| -rw-r--r-- | mercurial/web/templates/hgweb.wsgi.j2 | 18 |
6 files changed, 108 insertions, 0 deletions
diff --git a/mercurial/web/handlers/main.yaml b/mercurial/web/handlers/main.yaml new file mode 100644 index 0000000..9efe84d --- /dev/null +++ b/mercurial/web/handlers/main.yaml @@ -0,0 +1,5 @@ +--- + +- name: restart uwsgi + systemd: name="uwsgi.service" enabled="yes" daemon_reload="yes" state="restarted" + become: yes diff --git a/mercurial/web/tasks/main.yaml b/mercurial/web/tasks/main.yaml new file mode 100644 index 0000000..088a8fb --- /dev/null +++ b/mercurial/web/tasks/main.yaml @@ -0,0 +1,38 @@ +--- + +- name: pip install mercurial + become: yes + pip: name="mercurial" executable="pip3" + +- name: apt install uwsgi + become: yes + apt: name="{{item}}" + loop: + - "uwsgi" + - "uwsgi-plugin-python3" + notify: restart uwsgi + +- name: configure hgweb + become: yes + template: src="{{item}}.j2" dest="{{mercurial_uwsgi_root}}/{{item}}" + loop: + - "hgweb.config" + - "hgweb.wsgi" + notify: restart uwsgi + +- name: install uwsgi site + become: yes + template: src="hgweb.ini.j2" dest="/etc/uwsgi/apps-available/hgweb.ini" + notify: restart uwsgi + +- name: enable uwsgi site + become: yes + file: + src: "/etc/uwsgi/apps-available/hgweb.ini" + dest: "/etc/uwsgi/apps-enabled/hgweb.ini" + state: "link" + notify: restart uwsgi + +- name: ensure uwsgi service is started + become: yes + systemd: name="uwsgi.service" enabled="yes" diff --git a/mercurial/web/templates/hgweb.config.j2 b/mercurial/web/templates/hgweb.config.j2 new file mode 100644 index 0000000..881f8e4 --- /dev/null +++ b/mercurial/web/templates/hgweb.config.j2 @@ -0,0 +1,6 @@ +[paths] +/ = {{mercurial_uwsgi_repos}} + +[web] +deny_push = * +allow_archive = gz bz2 zip diff --git a/mercurial/web/templates/hgweb.ini.j2 b/mercurial/web/templates/hgweb.ini.j2 new file mode 100644 index 0000000..f65d440 --- /dev/null +++ b/mercurial/web/templates/hgweb.ini.j2 @@ -0,0 +1,8 @@ +[uwsgi] +processes = 2 +socket = unix:/run/uwsgi/app/hgweb/socket +chdir = {{mercurial_uwsgi_root}} +wsgi-file = hgweb.wsgi +uid = www-data +gid = www-data +plugins = python3 diff --git a/mercurial/web/templates/hgweb.nginx.conf.j2 b/mercurial/web/templates/hgweb.nginx.conf.j2 new file mode 100644 index 0000000..fbe6d21 --- /dev/null +++ b/mercurial/web/templates/hgweb.nginx.conf.j2 @@ -0,0 +1,33 @@ +server { + listen 80; + listen [::]:80; + server_name {{nginx_server_name}}; + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl http2; +# listen [::]:443 ssl ipv6only=on; + server_name {{nginx_server_name}}; + + ssl_certificate {{nginx_ssl_cert}}; + ssl_certificate_key {{nginx_ssl_privkey}}; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + + ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1; + ssl_stapling on; + ssl_stapling_verify on; + + location / { + include uwsgi_params; + uwsgi_param REMOTE_PORT $remote_port; + uwsgi_param SERVER_PORT $server_port; + uwsgi_param SERVER_PROTOCOL $server_protocol; + uwsgi_param UWSGI_SCHEME $scheme; + uwsgi_param SCRIPT_NAME /; + uwsgi_param AUTH_USER $remote_user; + uwsgi_param REMOTE_USER $remote_user; + uwsgi_pass unix:/run/uwsgi/app/hgweb/socket; + } +} diff --git a/mercurial/web/templates/hgweb.wsgi.j2 b/mercurial/web/templates/hgweb.wsgi.j2 new file mode 100644 index 0000000..16cc9fa --- /dev/null +++ b/mercurial/web/templates/hgweb.wsgi.j2 @@ -0,0 +1,18 @@ +# An example WSGI for use with mod_wsgi, edit as necessary +# See https://mercurial-scm.org/wiki/modwsgi for more information + +# Path to repo or hgweb config to serve (see 'hg help hgweb') +config = "{{mercurial_uwsgi_root}}/hgweb.config" + +# 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() + +# enable demandloading to reduce startup time +from mercurial import demandimport; demandimport.enable() + +from mercurial.hgweb import hgweb +application = hgweb(config.encode()) |
