Nuxt.js: How to deploy on Nginx server?

Created on 26 Sep 2017  路  8Comments  路  Source: nuxt/nuxt.js

This question is available on Nuxt.js community (#c1554)

Most helpful comment

Do you mean how to configure nginx as proxy?

map $sent_http_content_type $expires {
    "text/html"                 epoch;
    "text/html; charset=utf-8"  epoch;
    default                     off;
}

server {
    listen 80;
    server_name             your-domain;

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location / {

        expires $expires;

        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_read_timeout          1m;
        proxy_connect_timeout       1m;
        proxy_pass                          http://127.0.0.1:3000;
    }
}

All 8 comments

Do you mean how to configure nginx as proxy?

map $sent_http_content_type $expires {
    "text/html"                 epoch;
    "text/html; charset=utf-8"  epoch;
    default                     off;
}

server {
    listen 80;
    server_name             your-domain;

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location / {

        expires $expires;

        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_read_timeout          1m;
        proxy_connect_timeout       1m;
        proxy_pass                          http://127.0.0.1:3000;
    }
}

Thank you

@Atinux @alexchopin this could be something for the FAQ (deployment section)

@vuchl could you open a PR for it on nuxt/docs? :)

@awronski

````
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|js|pdf|txt){
root /www/xxxx/production/current/_nuxt;
}

````

when i config in nginx i got 404 error

how i resolve this prob

@naihe138
how do you use nuxt?

Is is:

  • standalone app?
  • as middleware with express?
  • as generated static?

i don,t know whether this is too late but i was also struggling to deploy my nuxt app using nginx and pm2...but this tutorial finally helped me Deploying nuxt with nginx and pm2

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surmon-china picture surmon-china  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

vadimsg picture vadimsg  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments