ember, nginx, reverse proxy

Home / nginx / ember, nginx, reverse proxy

Question:
I have my app deployed to a file server here at: http://example.com/my-team/my-app

We want our app to be facing at: http://amazingapp.com

So far this is what I have on nginx
server {
listen 80;
server_name http://amazingapp.com;
location / {
proxy_pass http://example.com/my-team/my-app/;
}
}
This works for initial http://amazingapp.com but any subsequent requests http://amazingapp.com/post/1/comment/2 result in 404

Most of the ember deploy examples have the file being served from the same location as the web server, using try_files $uri $uri/ index.html So i don’t believe i’m able to go down that path?

I’ve tried using regex on the location but that requires the proxy_pass to have parameters.

If you could point me in the right direction would be so grateful. Thanks in advance!


Answer:
Consider your config below
server {
listen 80;
server_name http://amazingapp.com;
location / {
proxy_pass http://example.com/my-team/my-app;
}
}
When you access http://amazingapp.com/abc your location / will cut abc out of it and append to proxy_pass. Making your url as http://example.com/my-team/my-appabc. Fix is quite simple, just add a trailing/` to your proxy_pass
server {
listen 80;
server_name http://amazingapp.com;
location / {
proxy_pass http://example.com/my-team/my-app/;
}
}
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *