Moving HTTP kiwix/help services to 9085/9086 ports. Nginx will serve HTTPS proxy for kiwix/help services at the old ports. Modifying apache2 to use HTTPS to serve map.

Using new https_proxy docker container to serve HTTPS for zim, map and help.
This commit is contained in:
Roland 2024-06-12 18:44:59 -06:00
parent ae61977f0b
commit 38de2f9b40
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
31 changed files with 450 additions and 244 deletions

View file

@ -19,6 +19,10 @@
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/nginx/cert.crt
SSLCertificateKeyFile /etc/nginx/cert.key
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular

View file

@ -25,93 +25,56 @@ http {
error_page 504 /error/50x.html;
server {
proxy_pass_header Host;
location ^~ /error/ {
internal;
alias /var/www/;
}
location /favicon.ico {
alias /opt/wrolpi/icon.ico;
}
location /apple-touch-icon.png {
alias /opt/wrolpi/icon.png;
}
location /50x.html {
alias /error/50x.html;
}
location /epub/epub.html {
alias /opt/wrolpi/app/public/epub/epub.html;
}
location /epub/epub.js {
alias /opt/wrolpi/app/public/epub/epub.js;
}
location /epub/jszip.min.js {
alias /opt/wrolpi/app/public/jszip.min.js;
}
listen 80;
listen [::]:80;
server_name _; # Default server for requests without "Host" header
location / {
# React APP
proxy_pass http://127.0.0.1:5000;
rewrite $1 break;
return 301 https://$host$request_uri;
}
}
location /sockjs-node {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
server {
listen 443 ssl;
listen [::]:443 ssl;
proxy_pass_header Host;
# Self-signed cert.
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
include /etc/nginx/conf.d/*;
}
# HTTPS Map is served by Apache2. This is because mod_tile.conf is required to render the map. renderd does not
# support nginx.
server {
# HTTPS Kiwix.
listen 8085 ssl;
listen [::]:8085 ssl;
proxy_pass_header Host;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
location / {
proxy_pass http://0.0.0.0:9085;
}
}
location /api {
proxy_pass http://127.0.0.1:8081;
rewrite /^api(.*)$ $1 break;
server {
# HTTPS Help.
listen 8086 ssl;
listen [::]:8086 ssl;
proxy_pass_header Host;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
location / {
proxy_pass http://0.0.0.0:9086;
}
location /docs {
proxy_pass http://127.0.0.1:8081;
rewrite /^docs(.*)$ $1 break;
}
location /media {
# The media files mounted in the docker volume
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
autoindex on;
autoindex_exact_size off;
alias /media/wrolpi;
}
location /download {
# Assume any request here is to download a file from the media directory.
if ( $request_filename ~ '^.*/(.+)$' ) {
# Always include the filename for downloads.
add_header Content-Disposition 'attachment; filename="$1"';
}
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
autoindex on;
autoindex_exact_size off;
alias /media/wrolpi;
}
}
}

View file

@ -1,15 +1 @@
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 8084
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Listen 8084

View file

@ -5,7 +5,7 @@ PartOf=wrolpi.target
[Service]
Environment=PYTHONUNBUFFERED=1
ExecStart=/opt/wrolpi/venv/bin/sanic main:api_app --host 0.0.0.0 --port 8081 --fast
ExecStart=/opt/wrolpi/venv/bin/sanic main:api_app --host 0.0.0.0 --port 8081 -w 2
ExecReload=/bin/kill -HUP $MAINPID
Group=wrolpi
User=wrolpi

View file

@ -0,0 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
Name=WROLPi Help Files
Type=Link
URL=/opt/wrolpi-help/docs/
Icon=/usr/share/icons/gnome/48x48/places/folder.png

View file

@ -0,0 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
Name=WROLPi Help
Type=Link
URL=https://127.0.0.1:8086
Icon=/opt/wrolpi-help/venv/lib/python3.11/site-packages/mkdocs/themes/mkdocs/img/favicon.ico

View file

@ -4,7 +4,7 @@ PartOf=wrolpi.target
[Service]
Type=simple
ExecStart=/bin/bash -c 'source /opt/wrolpi-help/venv/bin/activate && exec mkdocs serve -a 0.0.0.0:8086'
ExecStart=/bin/bash -c 'source /opt/wrolpi-help/venv/bin/activate && exec mkdocs serve -a 0.0.0.0:9086'
Group=wrolpi
User=wrolpi
WorkingDirectory=/opt/wrolpi-help/

View file

@ -0,0 +1,73 @@
# Nginx config for the WROLPi services.
#
# App
#
location /favicon.ico {
alias /opt/wrolpi/icon.ico;
}
location /apple-touch-icon.png {
alias /opt/wrolpi/icon.png;
}
location / {
# React APP
proxy_pass http://0.0.0.0:5000;
rewrite $1 break;
}
location /ws {
proxy_pass http://0.0.0.0:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
#
# API
#
location /api {
proxy_pass http://0.0.0.0:8081;
rewrite /^api(.*)$ $1 break;
}
location /docs {
proxy_pass http://0.0.0.0:8081;
rewrite /^docs(.*)$ $1 break;
}
location /media {
# The media files mounted in the docker volume
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
autoindex on;
autoindex_exact_size off;
alias /media/wrolpi;
}
location /download {
# Assume any request here is to download a file from the media directory.
if ( $request_filename ~ '^.*/(.+)$' ) {
# Always include the filename for downloads.
add_header Content-Disposition 'attachment; filename="$1"';
}
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
autoindex on;
autoindex_exact_size off;
alias /opt/media;
}

View file

@ -0,0 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
Name=WROLPi App
Type=Link
URL=https://127.0.0.1
Icon=/opt/wrolpi/icon.png