How to serve all routes on a production server exactly?

OK, I finally solve this issue by reading a great book: Nginx HTTP Server - Second Edition (Community Experience Distilled) , I should do more homework on Nginx, sometimes it is very useful.

Here’s solution:

server {
    listen 80 default;
    server_name my.domain.com;
    root /path/to/app/root;

    location / {
        rewrite ^ /index.html break;
    }
    
    location /assets/ {
        # do nothing and let nginx handle this as usual
    }
}
8 Likes