dimanche 7 janvier 2018

EmberJS & Nginx - Routes return 404's

It seems like a simple problem but I cannot find any official information about how to fix it.

The problem: Deploying an EmberJS app to Nginx - all routes return 404's.

The root route / works just fine. However any route besides / fails & returns 404's. Here's how I have my nginx.conf setup:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    root /home/ivo/myapp;
    index index.html;
    location / {
        include /etc/nginx/mime.types;
        try_files $uri $uri/ /index.html?/$request_uri;
    }
    }
}

This config is largely based on the nginx.conf that comes with the Nginx Docker image, which I am using.

From what I understand about Nginx, the location / block should be handling my routes, but for some reason it is not.

As a side note, I am shocked that EmberJS does not have any documentation about this at all. I even tried their Nginx config from their deployment section and it too did not work - http://ift.tt/2D5E4wq




Aucun commentaire:

Enregistrer un commentaire