Reverse proxy a URI to a Vagrant box
<p>I have a Wordpress Vagrant box that I access through the URL localhost:9001 (forwarded port.).</p>

<p>I am currently trying to make it accessible through the URL "molecare.dev".</p>

<p>I have created the line in the hosts file that catches that URL and points it to my localhost (this is working because I can see the nGinx splash page) but I am having trouble catching this URL in the server block and proxy_pass'ing this to the URL(localhost:9001).</p>

<p>Here is my /etc/nginx/sites-available/default file`server_name molecare.dev;</p>

<pre><code>server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.     
            try_files $uri $uri/ =404;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
</code></pre>

<p>I have written the following code which I think should do it but I don't know where to place it and if it is correct?</p>

<pre><code>server {
    listen 80;
    server_name molecare.dev;

    location / {
            proxy_pass localhost:9001;
    }
</code></pre>

<p>}</p>

<p>Can anyone see if this is correct and if so where I put this?</p>

<p>Thanks!</p>