olmesm / Local-Reverse-Proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local Reverse Proxy

Mock http://google.com using nginx as a reverse proxy to a locally running webserver.

Used for local testing of DNS resolving, and routing. Particularly useful for CMS migrations.

Requires

Setup

As a proof of working this is intended for mac setup only. This is replicatable, but untested for other platforms.

# Install switchhosts
brew cask install switchhosts

Add the following to switchhosts > preferences > Commands

sudo -S killall -HUP mDNSResponder

Create a new workspace "local-proxys" with the +

Add the following and then activate

127.0.0.1 google.com

In an additional terminal session

mkdir tmp

# Make an index.html file for serving
echo "this is not google" > tmp/index.html

# Serve the folder using a node webserver
npx serve tmp

Ensure the port used by the npx serve process is the same as the port set in the proxy_pass (most likely 5000)

Note We're not using https for this

docker-compose up

Navigate http://google.com