lundi 1 août 2016

Connect ember with an api server via nginx

I have a nginx proxy server that connects the api server to my ember client. This is working without any problems.
But when I hit the refresh button an any route except the root route the browser hits the proxy and it tries to serve the specified url. E.g. myapp.com/user hits the user route in the proxy server and I get the response not found 404.
I'm very new to nginx so I don't exactly know how to configure this steting. Here is my proxy config:

upstream querybuilder {
  # Path to Puma SOCK file, as defined previously
  server unix:/home/deploy/essence/shared/sockets/puma.sock fail_timeout=0;
}

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name essence;


  root /home/deploy/essence/public;
  try_files $uri/index.html $uri @querybuilder;

  location @querybuilder {
    proxy_pass http://localhost:2300;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    # try_files /fake_file @querybuilder;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}

The api server is a ruby/hanami application. But this is working without probles, so I don't think I have to reconfigure this.
Maybe this is important: We use ember simple auth for authentication.




Aucun commentaire:

Enregistrer un commentaire