|
| 1 | +server { |
| 2 | + listen 80 default_server; |
| 3 | + server_name preview.vim.org |
| 4 | + |
| 5 | + listen 443 ssl http2; |
| 6 | + |
| 7 | + #include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot |
| 8 | + location /.well-known { |
| 9 | + root /var/www/; |
| 10 | + allow all; |
| 11 | + try_files $uri =404; |
| 12 | + } |
| 13 | + |
| 14 | + location / { |
| 15 | + # Redirect non-https traffic to https |
| 16 | + if ($scheme != "https") { |
| 17 | + return 301 https://preview.vim.org; |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +server { |
| 23 | + server_name preview.vim.org; |
| 24 | + listen 443 ssl; |
| 25 | + |
| 26 | + location / { |
| 27 | + proxy_pass http://nextjs; |
| 28 | + proxy_set_header Host $host; |
| 29 | + proxy_set_header X-Real-IP $remote_addr; |
| 30 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 31 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 32 | + } |
| 33 | + |
| 34 | + location ^~ /api/ { |
| 35 | + proxy_pass http://strapi; |
| 36 | + proxy_http_version 1.1; |
| 37 | + proxy_set_header X-Forwarded-Host $host; |
| 38 | + proxy_set_header X-Forwarded-Server $host; |
| 39 | + proxy_set_header X-Real-IP $remote_addr; |
| 40 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 41 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 42 | + proxy_set_header Host $http_host; |
| 43 | + proxy_set_header Upgrade $http_upgrade; |
| 44 | + proxy_set_header Connection "Upgrade"; |
| 45 | + proxy_pass_request_headers on; |
| 46 | + proxy_set_header Origin http://localhost:1337; |
| 47 | + } |
| 48 | + |
| 49 | + location /cms/ { |
| 50 | + rewrite ^/cms/?(.*)$ /$1 break; |
| 51 | + proxy_pass http://strapi; |
| 52 | + proxy_http_version 1.1; |
| 53 | + proxy_set_header X-Forwarded-Host $host; |
| 54 | + proxy_set_header X-Forwarded-Server $host; |
| 55 | + proxy_set_header X-Real-IP $remote_addr; |
| 56 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 57 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 58 | + proxy_set_header Host $http_host; |
| 59 | + proxy_set_header Upgrade $http_upgrade; |
| 60 | + proxy_set_header Connection "Upgrade"; |
| 61 | + proxy_pass_request_headers on; |
| 62 | + proxy_set_header Origin http://localhost:1337; |
| 63 | + } |
| 64 | + |
| 65 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 66 | + add_header X-Frame-Options "SAMEORIGIN"; |
| 67 | + add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload"; |
| 68 | + add_header X-XSS-Protection "1; mode=block"; |
| 69 | + |
| 70 | + ssl_certificate /etc/letsencrypt/live/preview.vim.org/fullchain.pem; |
| 71 | + ssl_certificate_key /etc/letsencrypt/live/preview.vim.org/privkey.pem; |
| 72 | + |
| 73 | +} |
0 commit comments