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

11
docker/web/Dockerfile Normal file
View file

@ -0,0 +1,11 @@
FROM nginx:latest
# Create a self-signed cert and key pair for HTTPS.
RUN openssl genrsa -out /cert.key 2048
RUN openssl req -new -x509 -nodes -key /cert.key -out /cert.crt -days 3650 \
-subj "/C=US/ST=State/L=City/O=Org/OU=WROLPi/CN=wrolpi.local"
RUN chmod 777 /cert.key /cert.crt
RUN rm /etc/nginx/conf.d/default.conf
COPY docker/web/nginx.dev.conf /etc/nginx/nginx.conf
COPY docker/web/wrolpi.dev.conf /etc/nginx/conf.d/wrolpi.conf

44
docker/web/nginx.dev.conf Normal file
View file

@ -0,0 +1,44 @@
events {
}
http {
client_max_body_size 0;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
charset utf-8;
include mime.types;
types {
# Custom types for ebooks.
application/x-mobipocket-ebook mobi;
application/epub+zip epub;
}
server {
listen 80;
listen [::]:80;
server_name _; # Default server for requests without "Host" header
location / {
return 301 https://$host:8443$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
proxy_pass_header Host;
# Self-signed cert from Dockerfile build.
ssl_certificate /cert.crt;
ssl_certificate_key /cert.key;
include /etc/nginx/conf.d/*;
}
}

View file

@ -0,0 +1,73 @@
# Nginx config for the WROLPi services.
#
# App
#
location /favicon.ico {
alias /etc/nginx/favicon.ico;
}
location /apple-touch-icon.png {
alias /etc/nginx/icon.png;
}
location / {
# React APP
proxy_pass http://app:3000;
rewrite $1 break;
}
location /ws {
proxy_pass http://app:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
#
# API
#
location /api {
proxy_pass http://api:8081;
rewrite /^api(.*)$ $1 break;
}
location /docs {
proxy_pass http://api: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 /opt/media;
}
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;
}