Note To Self

nginx is super useful and easy to set up, but I forget how to set up a proxy to pass to a an internal service. This helps a lot.

For setting up a single page application (SPA) on NGINX (Engine-X, [I have to write it out since I always wrongly say "en-jinx"]), with HTML 5 style URLs

     server {
    listen 80;
    server_name serverinfo;{
{
    location  /go/ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://localhost:8234/;
    }

    location / {
        try_files = $uri /index.html;
        root c:/users/jason/documents/go/src/serverinfo/site;
    }
    }

This will try the file and write out index.html (rewrite) if it can't find it. All front end is static, and anything that starts with /go/ (for now, may change) will proxy pass to the service running, which is serving up data, written in Go and accessing MongoDB.

Also, I'm starting to use TypeScript and learn Angular2, so I will probably be posting stuff on that relatively soon.

blog comments powered by Disqus