From 5716ab58edf6621f9ffaa8e8edc8da70dd413820 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sat, 22 May 2021 13:30:52 -0500 Subject: [PATCH] Add config files --- blog.conf | 14 +++++ code.conf | 15 +++++ exozyme.conf | 26 +++++++++ game.conf | 11 ++++ gitea.conf | 26 +++++++++ jellyfin.conf | 84 +++++++++++++++++++++++++++ matrix.conf | 25 ++++++++ nextcloud.conf | 150 ++++++++++++++++++++++++++++++++++++++++++++++++ office.conf | 10 ++++ server.conf | 11 ++++ social.conf | 115 +++++++++++++++++++++++++++++++++++++ ta180m.conf.bak | 24 ++++++++ wiki.conf | 14 +++++ zabbix.conf | 43 ++++++++++++++ 14 files changed, 568 insertions(+) create mode 100644 blog.conf create mode 100644 code.conf create mode 100644 exozyme.conf create mode 100644 game.conf create mode 100644 gitea.conf create mode 100644 jellyfin.conf create mode 100644 matrix.conf create mode 100644 nextcloud.conf create mode 100644 office.conf create mode 100644 server.conf create mode 100644 social.conf create mode 100644 ta180m.conf.bak create mode 100644 wiki.conf create mode 100644 zabbix.conf diff --git a/blog.conf b/blog.conf new file mode 100644 index 0000000..607ca43 --- /dev/null +++ b/blog.conf @@ -0,0 +1,14 @@ +server { + listen 443 ssl; + server_name blog.exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + root /srv/http/blog; + index index.html; + + location / { + try_files $uri $uri/ =404; + } +} diff --git a/code.conf b/code.conf new file mode 100644 index 0000000..9b98033 --- /dev/null +++ b/code.conf @@ -0,0 +1,15 @@ +server { + listen 443 ssl; + server_name code.exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + location / { + proxy_pass http://localhost:6000; + proxy_set_header Host $host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection upgrade; + proxy_set_header Accept-Encoding gzip; + } +} diff --git a/exozyme.conf b/exozyme.conf new file mode 100644 index 0000000..3b38f96 --- /dev/null +++ b/exozyme.conf @@ -0,0 +1,26 @@ +server { + listen 80 default_server; + server_name _; + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl; + server_name exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + root /srv/http/exozy.me; + index index.html; + + location /.well-known/matrix/server { return 200 '{"m.server": "chat.exozy.me"}'; } + + location /.well-known/webfinger { + return 301 https://social.exozy.me$request_uri; + } + + location / { + try_files $uri $uri/ =404; + } +} diff --git a/game.conf b/game.conf new file mode 100644 index 0000000..d66bfaa --- /dev/null +++ b/game.conf @@ -0,0 +1,11 @@ +server { + listen 443 ssl; + server_name game.exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + location / { + proxy_pass http://localhost:5000; + } +} diff --git a/gitea.conf b/gitea.conf new file mode 100644 index 0000000..cf23092 --- /dev/null +++ b/gitea.conf @@ -0,0 +1,26 @@ +server { + server_name git.exozy.me; + + location / { + proxy_pass http://unix:/run/gitea/gitea.socket; + } + + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +} +server { + if ($host = git.exozy.me) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + server_name git.exozy.me; + return 404; # managed by Certbot + + +} diff --git a/jellyfin.conf b/jellyfin.conf new file mode 100644 index 0000000..c589567 --- /dev/null +++ b/jellyfin.conf @@ -0,0 +1,84 @@ +server { + listen 80; + listen [::]:80; + server_name media.exozy.me; + + # Uncomment to redirect HTTP to HTTPS + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name media.exozy.me; + + # use a variable to store the upstream proxy + # in this example we are using a hostname which is resolved via DNS + # (if you aren't using DNS remove the resolver line and change the variable to point to an IP address e.g `set $jellyfin 127.0.0.1`) + set $jellyfin 127.0.0.1; + resolver 127.0.0.1 valid=30; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + add_header Strict-Transport-Security "max-age=31536000" always; + ssl_trusted_certificate /etc/letsencrypt/live/exozy.me/chain.pem; + ssl_stapling on; + ssl_stapling_verify on; + + # Security / XSS Mitigation Headers + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Content-Type-Options "nosniff"; + + # Content Security Policy + # See: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP + # Enforces https content and restricts JS/CSS to origin + # External Javascript (such as cast_sender.js for Chromecast) must be whitelisted. + #add_header Content-Security-Policy "default-src https: data: blob:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://www.gstatic.com/cv/js/sender/v1/cast_sender.js https://www.youtube.com blob:; worker-src 'self' blob:; connect-src 'self'; object-src 'none'; frame-ancestors 'self'"; + + location = / { + return 302 https://$host/web/; + } + + location / { + # Proxy main Jellyfin traffic + proxy_pass http://$jellyfin:8096; + 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 X-Forwarded-Protocol $scheme; + proxy_set_header X-Forwarded-Host $http_host; + + # Disable buffering when the nginx proxy gets very resource heavy upon streaming + proxy_buffering off; + } + + # location block for /web - This is purely for aesthetics so /web/#!/ works instead of having to go to /web/index.html/#!/ + location = /web/ { + # Proxy main Jellyfin traffic + proxy_pass http://$jellyfin:8096/web/index.html; + 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 X-Forwarded-Protocol $scheme; + proxy_set_header X-Forwarded-Host $http_host; + } + + location /socket { + # Proxy Jellyfin Websockets traffic + proxy_pass http://$jellyfin:8096; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + 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 X-Forwarded-Protocol $scheme; + proxy_set_header X-Forwarded-Host $http_host; + } +} diff --git a/matrix.conf b/matrix.conf new file mode 100644 index 0000000..c7a7de8 --- /dev/null +++ b/matrix.conf @@ -0,0 +1,25 @@ +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + # For the federation port + listen 8448 http2 ssl default_server; + listen [::]:8448 http2 ssl default_server; + + server_name chat.exozy.me; + + ssl on; + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + location / { + proxy_pass http://localhost:8008; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + + # Nginx by default only allows file uploads up to 1M in size + # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml + client_max_body_size 50M; + } +} diff --git a/nextcloud.conf b/nextcloud.conf new file mode 100644 index 0000000..2c77c09 --- /dev/null +++ b/nextcloud.conf @@ -0,0 +1,150 @@ +upstream php-handler { + #server 127.0.0.1:9000; + #server unix:/var/run/php/php7.4-fpm.sock; + server unix:/run/nextcloud/nextcloud.sock; +} + +server { + listen 80; + listen [::]:80; + server_name cloud.exozy.me; + + # Enforce HTTPS + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name cloud.exozy.me; + + # Use Mozilla's guidelines for SSL/TLS settings + # https://mozilla.github.io/server-side-tls/ssl-config-generator/ + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + # HSTS settings + # WARNING: Only add the preload option once you read about + # the consequences in https://hstspreload.org/. This option + # will add the domain to a hardcoded list that is shipped + # in all major browsers and getting removed from this list + # could take several months. + add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;" always; + + # set max upload size + client_max_body_size 1G; + fastcgi_buffers 64 4K; + + # Enable gzip but do not remove ETag headers + 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/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; + + # Pagespeed is not supported by Nextcloud, so if your server is built + # with the `ngx_pagespeed` module, uncomment this line to disable it. + #pagespeed off; + + # HTTP response headers borrowed from Nextcloud `.htaccess` + 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 "none" always; + add_header X-XSS-Protection "1; mode=block" always; + + # Remove X-Powered-By, which is an information leak + fastcgi_hide_header X-Powered-By; + + # Path to the root of your installation + root /usr/share/webapps/nextcloud; + + # Specify how to handle directories -- specifying `/index.php$request_uri` + # here as the fallback means that Nginx always exhibits the desired behaviour + # when a client requests a path that corresponds to a directory that exists + # on the server. In particular, if that directory contains an index.php file, + # that file is correctly served; if it doesn't, then the request is passed to + # the front-end controller. This consistent behaviour means that we don't need + # to specify custom rules for certain paths (e.g. images and other assets, + # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus + # `try_files $uri $uri/ /index.php$request_uri` + # always provides the desired behaviour. + index index.php index.html /index.php$request_uri; + + # Rule borrowed from `.htaccess` to handle Microsoft DAV clients + 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; + } + + # Uncomment this line to enable webfinger (used by ActivityPub) + rewrite ^/.well-known/webfinger /public.php?service=webfinger last; + + # Make a regex exception for `/.well-known` so that clients can still + # access it despite the existence of the regex rule + # `location ~ /(\.|autotest|...)` which would otherwise handle requests + # for `/.well-known`. + location ^~ /.well-known { + # The following 6 rules are borrowed from `.htaccess` + + location = /.well-known/carddav { return 301 /remote.php/dav/; } + location = /.well-known/caldav { return 301 /remote.php/dav/; } + # Anything else is dynamically handled by Nextcloud + location ^~ /.well-known { return 301 /index.php$uri; } + + try_files $uri $uri/ =404; + } + + # Rules borrowed from `.htaccess` to hide certain paths from clients + location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } + location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } + + # Ensure this block, which passes PHP files to the PHP process, is above the blocks + # which handle static assets (as seen below). If this block is not declared first, + # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` + # to the URI, resulting in a HTTP 500 error response. + location ~ \.php(?:$|/) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + set $path_info $fastcgi_path_info; + + try_files $fastcgi_script_name =404; + + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $path_info; + fastcgi_param HTTPS on; + + fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice + fastcgi_param front_controller_active true; # Enable pretty urls + fastcgi_pass php-handler; + + fastcgi_intercept_errors on; + fastcgi_request_buffering off; + } + + location ~ \.(?:css|js|svg|gif)$ { + try_files $uri /index.php$request_uri; + expires 6M; # Cache-Control policy borrowed from `.htaccess` + access_log off; # Optional: Don't log access to assets + } + + location ~ \.woff2?$ { + try_files $uri /index.php$request_uri; + expires 7d; # Cache-Control policy borrowed from `.htaccess` + access_log off; # Optional: Don't log access to assets + } + + location / { + try_files $uri $uri/ /index.php$request_uri; + } +} diff --git a/office.conf b/office.conf new file mode 100644 index 0000000..43dd3ba --- /dev/null +++ b/office.conf @@ -0,0 +1,10 @@ +server { + listen 443 ssl; + server_name office.exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + client_max_body_size 20M; + include snippets/loolwsd.conf; +} diff --git a/server.conf b/server.conf new file mode 100644 index 0000000..5a5fef1 --- /dev/null +++ b/server.conf @@ -0,0 +1,11 @@ +server { + listen 443 ssl; + server_name server.exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + location / { + proxy_pass https://localhost:6000; + } +} diff --git a/social.conf b/social.conf new file mode 100644 index 0000000..7c81eea --- /dev/null +++ b/social.conf @@ -0,0 +1,115 @@ +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 levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g; + +server { + listen 80; + listen [::]:80; + server_name social.exozy.me; + 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 social.exozy.me; + + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + + # Uncomment these lines once you acquire a certificate: + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + 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; + + add_header Strict-Transport-Security "max-age=31536000"; + + location / { + try_files $uri @proxy; + } + + location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) { + add_header Cache-Control "public, max-age=31536000, immutable"; + add_header Strict-Transport-Security "max-age=31536000"; + try_files $uri @proxy; + } + + location /sw.js { + add_header Cache-Control "public, max-age=0"; + add_header Strict-Transport-Security "max-age=31536000"; + try_files $uri @proxy; + } + + 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; + add_header Strict-Transport-Security "max-age=31536000"; + + tcp_nodelay on; + } + + 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; + + tcp_nodelay on; + } + + error_page 500 501 502 503 504 /500.html; +} diff --git a/ta180m.conf.bak b/ta180m.conf.bak new file mode 100644 index 0000000..981451a --- /dev/null +++ b/ta180m.conf.bak @@ -0,0 +1,24 @@ +server { + listen 443 ssl; + server_name ta180m.exozy.me; + + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + + location / { + # Required to proxy the connection to Cockpit + proxy_pass https://127.0.0.1:9090; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + + # Required for web sockets to function + proxy_http_version 1.1; + proxy_buffering off; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + # Pass ETag header from Cockpit to clients. + # See: https://github.com/cockpit-project/cockpit/issues/5239 + gzip off; + } +} diff --git a/wiki.conf b/wiki.conf new file mode 100644 index 0000000..d1c603d --- /dev/null +++ b/wiki.conf @@ -0,0 +1,14 @@ +server { + listen 443; + server_name wiki.exozy.me; + ssl_certificate /etc/letsencrypt/live/exozy.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/exozy.me/privkey.pem; + root /usr/share/webapps/mediawiki; + index index.php; + charset utf-8; +# For correct file uploads + client_max_body_size 100m; # Equal or more than upload_max_filesize in /etc/php7/php.ini + client_body_timeout 60; + include mediawiki.conf; + +} diff --git a/zabbix.conf b/zabbix.conf new file mode 100644 index 0000000..3341507 --- /dev/null +++ b/zabbix.conf @@ -0,0 +1,43 @@ +server { + listen 80; + server_name 192.168.1.13; + + root /srv/http; + index index.php; + + location /zabbix { + if ($scheme ~ ^http:){ + rewrite ^(.*)$ https://$host$1 permanent; + } + alias /srv/http/zabbix; + index index.php; + error_page 403 404 502 503 504 /zabbix/index.php; + + location ~ \.php$ { + if (!-f $request_filename) { return 404; } + expires epoch; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_intercept_errors on; + + fastcgi_read_timeout 120s; + fastcgi_send_timeout 120s; + + fastcgi_index index.php; + fastcgi_pass unix:/run/php-fpm/php-fpm.sock; + + # fastcgi_param PHP_VALUE " + # max_execution_time=300 + # max_input_time=300 + # post_max_size=16M + # "; + } + + location ~ \.(jpg|jpeg|gif|png|ico)$ { + access_log off; + expires 33d; + } + } +} + +