moeallenz

nginx reverse proxy for wasabi

Jun 12th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.98 KB | None | 0 0
  1. upstream wasabi {
  2.     server s3.wasabisys.com:443 max_conns=128;
  3. }
  4.  
  5. server {
  6.   listen 80;
  7.   listen [::]:80;
  8.   server_name <your.domain.example.com>;
  9.  
  10.   access_log /var/log/nginx/access-<your.domain.example.com>.log main;
  11.   error_log  /var/log/nginx/error-<your.domain.example.com>.log;
  12.  
  13.   root /srv/www/letsencrypt;
  14.   location /.well-known/ {
  15.     #alias /srv/www/letsencrypt/.well-known;
  16.     default_type "text/plain";
  17.     allow all;
  18.   }
  19.   location / {
  20.     return 301 https://$host$request_uri;
  21.   }
  22. }
  23.  
  24. server {
  25.   listen 443 ssl http2;
  26.   listen [::]:443 ssl http2;
  27.   server_name <your.domain.example.com>;
  28.  
  29.   access_log /var/log/nginx/access-<your.domain.example.com>.log main;
  30.   error_log  /var/log/nginx/error-<your.domain.example.com>.log;
  31.  
  32.   ssl_certificate     /etc/letsencrypt/live/<your.domain.example.com>/fullchain.pem;
  33.   ssl_certificate_key /etc/letsencrypt/live/<your.domain.example.com>/privkey.pem;
  34.  
  35.   keepalive_timeout    70;
  36.   sendfile             on;
  37.   client_max_body_size 64m;
  38.  
  39.   add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; Preload";
  40.   add_header Content-Security-Policy "style-src 'self' 'unsafe-inline'; frame-ancestors 'none'; object-src 'self'; script-src 'self'; base-uri 'none'; img-src data: https:; media-src data: https:";
  41.  
  42.   location / {
  43.     return 404;
  44.   }
  45.   location /<your-bucket-name> {
  46.     try_files $uri @proxy;
  47.   }
  48.  
  49.   location ~ ^/(packs|<your-bucket-name>/media_attachments/files|<your-bucket-name>/accounts/avatars) {
  50.     add_header Cache-Control "public, max-age=31536000, immutable";
  51.     try_files $uri @proxy;
  52.   }
  53.  
  54.   location @proxy {
  55.     proxy_set_header Host "s3.wasabisys.com";
  56.     proxy_set_header X-Real-IP $remote_addr;
  57.     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  58.     proxy_set_header X-Forwarded-Proto https;
  59.  
  60.     #resolver 1.1.1.1;
  61.  
  62.     proxy_pass https://wasabi;
  63.     proxy_redirect off;
  64.     proxy_http_version 1.1;
  65.   }
  66.  
  67.   error_page 500 501 502 503 504 /500.html;
  68. }
Add Comment
Please, Sign In to add comment