mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 01:46:18 -05:00
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:
parent
ae61977f0b
commit
38de2f9b40
31 changed files with 450 additions and 244 deletions
|
|
@ -6,4 +6,4 @@ COPY docker/help/wrolpi-help /opt/wrolpi-help
|
|||
RUN pip3 install -r /opt/wrolpi-help/requirements.txt
|
||||
|
||||
ENTRYPOINT ["mkdocs"]
|
||||
CMD ["serve", "-a", "0.0.0.0:8086"]
|
||||
CMD ["serve", "-a", "0.0.0.0:80"]
|
||||
|
|
|
|||
18
docker/help/nginx.help.conf
Normal file
18
docker/help/nginx.help.conf
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
ssl_certificate /cert.crt;
|
||||
ssl_certificate_key /cert.key;
|
||||
|
||||
location / {
|
||||
proxy_pass http://help:80;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
docker/https_proxy/Dockerfile
Normal file
12
docker/https_proxy/Dockerfile
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# This Dockerfile is used as a reverse proxy to serve a HTTPS nieve service with HTTPS.
|
||||
FROM nginx:latest as https_proxy
|
||||
|
||||
# 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
|
||||
|
||||
# Copy Nginx configuration
|
||||
COPY docker/https_proxy/nginx.proxy.conf /etc/nginx/nginx.conf
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
18
docker/https_proxy/nginx.proxy.conf
Normal file
18
docker/https_proxy/nginx.proxy.conf
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
ssl_certificate /cert.crt;
|
||||
ssl_certificate_key /cert.key;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:80;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
docker/map/nginx.map.conf
Normal file
18
docker/map/nginx.map.conf
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
ssl_certificate /cert.crt;
|
||||
ssl_certificate_key /cert.key;
|
||||
|
||||
location / {
|
||||
proxy_pass http://map:80;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
docker/web/Dockerfile
Normal file
11
docker/web/Dockerfile
Normal 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
44
docker/web/nginx.dev.conf
Normal 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/*;
|
||||
}
|
||||
|
||||
}
|
||||
73
docker/web/wrolpi.dev.conf
Normal file
73
docker/web/wrolpi.dev.conf
Normal 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;
|
||||
}
|
||||
|
|
@ -4,4 +4,4 @@ rm -f /library.xml
|
|||
# Find all Zim files and import them.
|
||||
find /media/wrolpi -iname '*.zim' -exec /import_zim.sh {} \;
|
||||
|
||||
kiwix-serve --monitorLibrary --library /library.xml --address 0.0.0.0 --port 8085
|
||||
kiwix-serve --monitorLibrary --library /library.xml --address 0.0.0.0 --port 80
|
||||
|
|
|
|||
18
docker/zim/nginx.zim.conf
Normal file
18
docker/zim/nginx.zim.conf
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
ssl_certificate /cert.crt;
|
||||
ssl_certificate_key /cert.key;
|
||||
|
||||
location / {
|
||||
proxy_pass http://zim:80;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue