Last active
April 16, 2019 22:24
-
-
Save hawkapparel/34cafb96b9dace4b9a9996b5640d1e65 to your computer and use it in GitHub Desktop.
Configuration reverse proxy nginx + nuxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=nuxt-cache:25m max_si$ | |
| map $sent_http_content_type $expires { | |
| #"text/html" 1h; # set this to your needs | |
| #"text/html; charset=utf-8" 1h; # set this to your needs | |
| default 30d; # set this to your needs | |
| } | |
| server { | |
| listen 80; # the port nginx is listening on | |
| server_name yourdomain.com; # setup your domain here | |
| gzip on; | |
| #gzip_types text/plain application/xml text/css application/javascript; | |
| gzip_types text/plain text/css text/xml application/json application/javasc$ | |
| gzip_min_length 1000; | |
| charset utf-8; | |
| root /var/www/html/yourprojectnuxt/.nuxt; | |
| location ~* \.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|css)$ { | |
| expires $expires; | |
| add_header Pragma public; | |
| add_header Cache-Control "public"; | |
| try_files $uri $uri/ @proxy; | |
| } | |
| location / { | |
| expires $expires; | |
| #add_header Content-Security-Policy "default-src 'self' 'unsafe-inline'$ | |
| add_header Strict-Transport-Security "max-age=31536000; includeSubDomai$ | |
| add_header X-Frame-Options "SAMEORIGIN"; | |
| try_files $uri $uri/index.html @proxy; # for generate.subFolders: true | |
| # try_files $uri $uri.html @proxy; # for generate.subFolders: false | |
| } | |
| location @proxy { | |
| expires $expires; | |
| #add_header Content-Security-Policy "default-src 'self' 'unsafe-inline'$ | |
| add_header Strict-Transport-Security "max-age=31536000; includeSubDomai$ | |
| add_header X-Frame-Options "SAMEORIGIN"; | |
| add_header X-Cache-Status $upstream_cache_status; | |
| proxy_redirect off; | |
| 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_ignore_headers Cache-Control; | |
| proxy_http_version 1.1; | |
| proxy_read_timeout 1m; | |
| proxy_connect_timeout 1m; | |
| proxy_pass http://127.0.0.1:3000; # set the adress of $ | |
| #proxy_cache nuxt-cache; | |
| proxy_cache_bypass $arg_nocache; # probably better to change t$ | |
| #proxy_cache_valid 200 302 60m; # set this to your needs | |
| proxy_cache_valid 302 60m; | |
| proxy_cache_valid 404 1m; # set this to your needs | |
| proxy_cache_lock on; | |
| proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; | |
| proxy_cache_key $uri$is_args$args; | |
| #proxy_cache_purge PURGE from 127.0.0.1; | |
| } | |
| listen 443 ssl; # managed by Certbot | |
| ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by$ | |
| ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # managed $ | |
| include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
| ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment