Skip to content

Instantly share code, notes, and snippets.

@zdwolfe
Last active October 1, 2018 06:38
  • Star 17 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zdwolfe/6721115 to your computer and use it in GitHub Desktop.
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
Copy link

yanilkr 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
Copy link

yanilkr commented Apr 24, 2014

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

@cjus
Copy link

cjus commented Jul 19, 2014

@juancarloscruzd
Copy link

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
Copy link

imranattask 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