Add Nginx config

This commit is contained in:
Edgar P. Burkhart 2023-05-16 14:57:19 +02:00
parent 57fda34995
commit 4da71a3fc4
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
23 changed files with 525 additions and 0 deletions

4
src/Nginx/README.md Normal file
View file

@ -0,0 +1,4 @@
# Nginx
<https://wiki.archlinux.org/title/Nginx>
Install to `/etc/nginx/`.

View file

@ -0,0 +1 @@
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

View file

@ -0,0 +1,8 @@
ssl_certificate /etc/letsencrypt/live/edgarpierre.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/edgarpierre.fr/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
include conf/00-hsts.conf;

View file

@ -0,0 +1,8 @@
ssl_certificate /etc/letsencrypt/live/huascaran.burkhart.ovh/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/huascaran.burkhart.ovh/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
include conf/00-hsts.conf;

View file

@ -0,0 +1,4 @@
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;

View file

@ -0,0 +1,2 @@
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

View file

@ -0,0 +1,3 @@
location = /robots.txt {
return 200 "User-agent: *\nDisallow: /\n";
}

48
src/Nginx/nginx.conf Normal file
View file

@ -0,0 +1,48 @@
events {
worker_connections 1024;
}
http {
charset utf-8;
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
server_tokens off;
log_not_found off;
types_hash_max_size 4096;
client_max_body_size 16M;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
include sites-enabled/*;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
include conf/10-certbot-edgarpierre.conf;
include conf/00-hsts.conf;
return 404;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
include conf/00-hsts.conf;
return 301 https://$host$request_uri;
}
}

View file

@ -0,0 +1,10 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name autoconfig.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
root /data/srv/thunderbird_autoconfig/srv/;
}
}

View file

@ -0,0 +1,13 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name cockpit.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
include conf/50-ws-proxy.conf;
proxy_pass http://localhost:9090;
}
}

View file

@ -0,0 +1,14 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name docs.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
root /data/srv/edoceo/;
location /static {
expires 1y;
add_header Cache-Control "public";
}
}
}

View file

@ -0,0 +1,12 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name git.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
proxy_pass http://unix:/run/forgejo/forgejo.socket;
}
}

View file

@ -0,0 +1,13 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name galene.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
include conf/50-ws-proxy.conf;
proxy_pass https://localhost:8443;
}
}

View file

@ -0,0 +1,19 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name dash.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
proxy_pass http://unix:/run/grafana/grafana.socket;
}
location /api/live/ {
include conf/50-proxy.conf;
include conf/50-ws-proxy.conf;
proxy_pass http://unix:/run/grafana/grafana.socket;
}
}

View file

@ -0,0 +1,12 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name influxdb.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
proxy_pass http://localhost:8086;
}
}

View file

@ -0,0 +1,148 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream backend {
server 127.0.0.1:3000 fail_timeout=0;
}
upstream streaming {
server 127.0.0.1:4000 fail_timeout=0;
}
proxy_cache_path /var/cache/nginx-mastodon levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;
server {
listen 80;
listen [::]:80;
server_name m.edgarpierre.fr;
root /var/lib/mastodon/public;
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name m.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
keepalive_timeout 70;
sendfile on;
client_max_body_size 80m;
root /var/lib/mastodon/public;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon;
location / {
try_files $uri @proxy;
}
location = /sw.js {
add_header Cache-Control "public, max-age=604800, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/assets/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/avatars/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/emoji/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/headers/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/packs/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/shortcuts/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/sounds/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ~ ^/system/ {
add_header Cache-Control "public, max-age=2419200, immutable";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
try_files $uri =404;
}
location ^~ /api/v1/streaming {
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;
proxy_set_header Proxy "";
proxy_pass http://streaming;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
tcp_nodelay on;
}
location @proxy {
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;
proxy_set_header Proxy "";
proxy_pass_header Server;
proxy_pass http://backend;
proxy_buffering on;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache CACHE;
proxy_cache_valid 200 7d;
proxy_cache_valid 410 24h;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
tcp_nodelay on;
}
error_page 404 500 501 502 503 504 /500.html;
}

View file

@ -0,0 +1,109 @@
map $arg_v $asset_immutable {
"" "";
default "immutable";
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name cloud.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
root /usr/share/webapps/nextcloud;
include conf/00-hsts.conf;
server_tokens off;
client_max_body_size 512M;
client_body_timeout 300s;
fastcgi_buffers 64 4K;
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
client_body_buffer_size 512k;
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-XSS-Protection "1; mode=block" always;
fastcgi_hide_header X-Powered-By;
include mime.types;
types {
application/javascript js mjs;
}
index index.php index.html /index.php$request_uri;
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ^~ /.well-known {
location = /.well-known/carddav { return 301 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
return 301 /index.php$request_uri;
}
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
location ~ \.php(?:$|/) {
include uwsgi_params;
uwsgi_modifier1 14;
uwsgi_hide_header X-Frame-Options;
uwsgi_hide_header X-XSS-Protection;
uwsgi_hide_header X-Content-Type-Options;
uwsgi_hide_header X-Robots-Tag;
uwsgi_hide_header X-Download-Options;
uwsgi_hide_header X-Permitted-Cross-Domain-Policies;
uwsgi_pass unix:/run/nextcloud/nextcloud.sock;
}
location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463, $asset_immutable";
access_log off;
location ~ \.wasm$ {
default_type application/wasm;
}
}
location ~ \.woff2?$ {
try_files $uri /index.php$request_uri;
expires 7d;
access_log off;
}
location /remote {
return 301 /remote.php$request_uri;
}
location / {
try_files $uri $uri/ /index.php$request_uri;
}
}

View file

@ -0,0 +1,13 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name photos.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
include conf/50-ws-proxy.conf;
proxy_pass http://localhost:8123;
}
}

View file

@ -0,0 +1,13 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name public.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
auth_basic "Protected";
auth_basic_user_file passwd;
location / {
proxy_pass https://localhost:39528;
}
}

View file

@ -0,0 +1,15 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name cal.edgarpierre.fr calendrier.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
proxy_set_header X-Script-Name "";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass_header Authorization;
proxy_pass http://localhost:5232;
}
}

View file

@ -0,0 +1,15 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sync.edgarpierre.fr partage.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
proxy_pass https://localhost:8384/;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
}

View file

@ -0,0 +1,20 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name pass.edgarpierre.fr coffre.edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
include conf/50-proxy.conf;
proxy_pass http://localhost:8011;
}
location /notifications/hub {
include conf/50-ws-proxy.conf;
proxy_pass http://localhost:3012;
}
location /notifications/hub/negociate {
proxy_pass http://localhost:8011;
}
}

View file

@ -0,0 +1,21 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.edgarpierre.fr edgarpierre.fr;
include conf/10-certbot-edgarpierre.conf;
location / {
root /data/srv/web2.0/src/;
location /static {
expires 1y;
add_header Cache-Control "public";
}
}
location ~ ^(/_matrix|/_synapse/client|/.well-known) {
include conf/50-proxy.conf;
proxy_pass http://localhost:8008;
client_max_body_size 50M;
}
}