I’m developing an application that requires authentication, but doesn’t do it directly.

In production, you log in at (not a real URL), and then a link takes you to When you visit /myproduct, you’re accessing a different server from /. To handle authentication, myproduct checks a session cookie that was assigned by / against a Redis store. If the session is valid, you’re allowed in, otherwise you’re redirected to / to log in.

Vagrant VM

I’ve got a Vagrant virtual machine set up to host my tech stack - which in this case is the app that handles logins, a MySQL database and a Redis store (to support said logins). I have an entry in my hosts file to point a hostname at the IP address the machine is located at:

With this, I can go to in my browser to log in, like in prod.

Local Development

When developing my app, it runs on localhost. This presents a problem - I can log in and acquire a session at, but my app running on localhost can’t read the session cookie, because the cookie is set against

Enter NGINX!

I installed NGINX on my local machine and added a new server block, which looks like this:

server {
    listen 80;

    location /dev {
        proxy_pass http://localhost/myproduct;

    location / {

With this block, requests to will route to the local development environment, whereas all other requests to will route to the Vagrant machine. This means that they can now share cookies and authentication will work as in prod.