Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic nginx configuration for AngularJS html5Mode
server {
listen 0.0.0.0:12345;
location / {
root /home/zdwolfe/src/angularAWS/app;
try_files $uri $uri/ /index.html =404;
}
}
@yanilkr

This comment has been minimized.

Copy link

commented Apr 24, 2014

this does not work well when the angular urls are like this
http://serverpath/a/b
all the css and js files will try to load from http://serverpath/a/

@yanilkr

This comment has been minimized.

Copy link

commented Apr 24, 2014

This gist has little more details
https://gist.github.com/shreyas-satish/8452999

@cjus

This comment has been minimized.

Copy link

commented Jul 19, 2014

@juancarloscruzd

This comment has been minimized.

Copy link

commented May 12, 2015

This a dirty solution, but worked for me.
Sacrifice my 404 page, but fix the main problem.

server {
    listen 0.0.0.0:12345;

    location / {
        root /home/zdwolfe/src/angularAWS/app;
        try_files $uri $uri/ /index.html =404;
    }

    error_page 404 /index.html
}
@imranattask

This comment has been minimized.

Copy link

commented Aug 4, 2018

I want ionic web app to run in subfolder
location /con { root /var/www/html/p/ionicsub/www; index index.html index.htm; try_files $uri $uri/ /index.html =404; }

But this didn't work 404 for the js and css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.