Skip to content

Instantly share code, notes, and snippets.

@mygoare
Forked from namdau/vue-nginx.conf
Created July 14, 2019 08:43
Show Gist options
  • Select an option

  • Save mygoare/7692f5e508d81c4b587ffd3ad2bd6e49 to your computer and use it in GitHub Desktop.

Select an option

Save mygoare/7692f5e508d81c4b587ffd3ad2bd6e49 to your computer and use it in GitHub Desktop.

Revisions

  1. @namdau namdau created this gist Jul 31, 2017.
    64 changes: 64 additions & 0 deletions vue-nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    server {
    server_name default_server;
    # This is for Let's Encrypt certification renewal
    include /etc/nginx/snippets/letsencrypt.conf;
    # Redirect to https
    location / {
    return 301 https://$server_name$request_uri;
    }
    }

    upstream api_server {
    server localhost:7000; # API upstream
    }

    server {
    # SSL configuration
    ssl on;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    include /etc/nginx/snippets/ssl-app.conf;
    include /etc/nginx/snippets/ssl-params.conf;

    access_log /var/log/nginx/app_access.log;
    error_log /var/log/nginx/app_error.log;

    server_name default_server;
    root /path/to/dist/;
    index index.html;

    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

    location / {
    try_files $uri $uri/ @rewrites;
    }

    location @rewrites {
    rewrite ^(.+)$ /index.html last;
    }

    location /api {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Host $remote_addr;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass https://api_server/api;
    proxy_ssl_session_reuse off;
    proxy_redirect off;
    }

    location ~ /\. {
    deny all;
    }
    }