Skip to content

Instantly share code, notes, and snippets.

@SwadhInz
Forked from edm00se/ReadMe.md
Created January 26, 2021 23:52
Show Gist options
  • Save SwadhInz/dce94863f735a5455a9221cbdf514e19 to your computer and use it in GitHub Desktop.
Save SwadhInz/dce94863f735a5455a9221cbdf514e19 to your computer and use it in GitHub Desktop.
Sample nginx.conf settings to perform reverse proxy functionality to.

Read Me

In order to access a server hosted within a vm, for development purposes, which is restricted to same origin / localhost only requests, I set up a siple nginx reverse proxy to forward my requests.

Steps

  1. To install in a Windows VM, download and install nginx from the current, stable release; I installed to C:\nginx\
  2. Executing the nginx.exe in your install path will start the nginx server with default configuration, edit the conf/nginx.conf file with the marked changes in the file of the same name in this gist.

Description

The config file contains a server {} block, inside which is a location / {} block. Inside that location block, we need to comment out the root and index assignment and add in a proxy_pass http://127.0.0.1:8080; line and a proxy_http_version 1.1; line.

Profit

...
server {
listen 80;
server_name localhost;
...
#location / {
# root html;
# index index.html index.htm;
#}
location / {
# Backend server to forward requests to/from
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
}
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment