Giter VIP home page Giter VIP logo

local-reverse-proxy's Introduction

Setup local reverse proxy

MacOS

To allow this to work on your local machine, follow these steps:

  1. Install nginx on your machine. For OSX users, you can run brew install nginx. If you don't have homebrew, you should install it.

  2. After install, run: sudo nginx

  3. Update the nginx configuration file in /usr/local/etc/nginx/nginx.conf with the following values in the http module.

server {
  listen                  80;
  listen                  443 ssl;
  ssl_certificate         /etc/ssl/certs/myssl.crt;
  ssl_certificate_key     /etc/ssl/private/myssl.key;
  server_name             myApp;

  # Backend Service
  location /local {
      proxy_pass  http://localhost:8000;
  }
  
  # Frontend
  location / {
      proxy_pass  http://localhost:3000/;
  }
}
  1. Run sudo nginx -s stop and sudo nginx to update nginx with the new configurations.

  2. Update your hosts file in /etc/hosts file with the following values.

127.0.0.1	    local.myapp.com

Linux (Ubuntu or Ubuntu-based distro)

With Ubuntu, the setup is very similar to MacOS, but ever so slightly different.

  1. Install nginx on your machine using sudo apt install nginx.

  2. Create a new file for the reverse proxy at /etc/nginx/sites-available/reverse-proxy.conf with the contents from the MacOS section (step 2) above.

  3. Create a symbolic link to the file in sites-enabled using sudo ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/reverse-proxy.conf

  4. Run sudo nginx -s stop and sudo nginx to update nginx with the new configurations.

  5. Update your hosts file in /etc/hosts file with the following values from the MacOS section above (step 4).

Using https locally

To test https locally, run the script generate-self-signed-cert-locally.sh. Enter a passphrase, but don't worry about all the other details.

Then ensure you include the ssl_certificate and ssl_certificate_key values in your server definition within your nginx configuration file located at: /usr/local/etc/nginx/nginx.conf. It should look something like:

server {
    listen               443 ssl;
    ssl_certificate      /etc/ssl/certs/myssl.crt;
    ssl_certificate_key  /etc/ssl/private/myssl.key;
    server_name SERVER_NAME.com;
    location / {
    }
}

local-reverse-proxy's People

Contributors

clementohnz avatar

Stargazers

Venky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.