Refactor Nginx config: improve proxy setup for Bitwarden with upstream directives, better WebSocket and HTTP/2 support; add Laravel template configuration.
This commit is contained in:
parent
ab914a66b6
commit
ae96bf59d6
@ -1,50 +1,68 @@
|
|||||||
# generated 2024-06-16, Mozilla Guideline v5.7, nginx 1.18.0, OpenSSL 3.0.2, modern configuration
|
# The `upstream` directives ensure that you have a http/1.1 connection
|
||||||
# https://ssl-config.mozilla.org/#server=nginx&version=1.18.0&config=modern&openssl=3.0.2&guideline=5.7
|
# This enables the keepalive option and better performance
|
||||||
|
#
|
||||||
|
# Define the server IP and ports here.
|
||||||
|
upstream vaultwarden-default {
|
||||||
|
zone vaultwarden-default 64k;
|
||||||
|
server router.tradewind.vip:10060;
|
||||||
|
keepalive 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Needed to support websocket connections
|
||||||
|
# See: https://nginx.org/en/docs/http/websocket.html
|
||||||
|
# Instead of "close" as stated in the above link we send an empty value.
|
||||||
|
# Else all keepalive connections will not work.
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' "";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Redirect HTTP to HTTPS
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
|
server_name bitwarden.tradewind.vip;
|
||||||
|
|
||||||
server_name bitwarden.tradewind.vip;
|
return 301 https://$host$request_uri;
|
||||||
|
|
||||||
location / {
|
|
||||||
return 301 https://$host$request_uri;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
# For older versions of nginx appended http2 to the listen line after ssl and remove `http2 on`
|
||||||
listen [::]:443 ssl http2;
|
listen 443 ssl;
|
||||||
|
listen [::]:443 ssl;
|
||||||
server_name bitwarden.tradewind.vip;
|
# http2 on;
|
||||||
|
server_name bitwarden.tradewind.vip;
|
||||||
# Allow large attachments
|
|
||||||
client_max_body_size 128M;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
resolver 223.5.5.5;
|
|
||||||
set $router "router.tradewind.vip";
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_pass http://$router:10060;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
# Specify SSL Config when needed
|
||||||
ssl_certificate /etc/letsencrypt/live/tradewind.vip/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/tradewind.vip/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/tradewind.vip/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/tradewind.vip/privkey.pem;
|
||||||
ssl_session_timeout 1d;
|
ssl_session_timeout 1d;
|
||||||
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
||||||
ssl_session_tickets off;
|
ssl_session_tickets off;
|
||||||
|
|
||||||
# modern configuration
|
client_max_body_size 525M;
|
||||||
ssl_protocols TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers off;
|
|
||||||
|
|
||||||
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
|
proxy_http_version 1.1;
|
||||||
add_header Strict-Transport-Security "max-age=63072000" always;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
|
||||||
# replace with the IP address of your resolver
|
proxy_set_header Host $host;
|
||||||
resolver 223.5.5.5;
|
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;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://vaultwarden-default;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optionally add extra authentication besides the ADMIN_TOKEN
|
||||||
|
# Remove the comments below `#` and create the htpasswd_file to have it active
|
||||||
|
#
|
||||||
|
#location /admin {
|
||||||
|
# # See: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
|
||||||
|
# auth_basic "Private";
|
||||||
|
# auth_basic_user_file /path/to/htpasswd_file;
|
||||||
|
#
|
||||||
|
# proxy_pass http://vaultwarden-default;
|
||||||
|
#}
|
||||||
|
}
|
34
sites-available/laravel_template
Normal file
34
sites-available/laravel_template
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name example.com;
|
||||||
|
root /example.com/public;
|
||||||
|
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
|
add_header X-Content-Type-Options "nosniff";
|
||||||
|
|
||||||
|
index index.html index.htm index.php;
|
||||||
|
|
||||||
|
charset utf-8;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /favicon.ico { access_log off; log_not_found off; }
|
||||||
|
location = /robots.txt { access_log off; log_not_found off; }
|
||||||
|
|
||||||
|
error_page 404 /index.php;
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.(?!well-known).* {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user