Skip to content

Instantly share code, notes, and snippets.

@Mozartted
Created May 23, 2018 04:56
Show Gist options
  • Save Mozartted/1e249bafa9fcfbd5084ac22683545bed to your computer and use it in GitHub Desktop.
Save Mozartted/1e249bafa9fcfbd5084ac22683545bed to your computer and use it in GitHub Desktop.
location /match/here {
proxy_pass http://ourserver2here.com;
}
```
In the above setup, no URI is given at the end of the server in the proxy pass definition. In this case a request such as **/match/here/please**, This request would be sent to ourserver2here as https://ourserver2here/match/here/please. Pretty convenient right?
## Reverse Proxying
This is one type of proxying that’s particularly interesting, let have a look at what Wikipedia describes it as since those guys are incredibly good at describing things.
> In computer networks, a **reverse proxy** is a type of **proxy** server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as if they originated from the Web server itself.
There’s a virtual description
![source - wikipedia - such good people](https://d2mxuefqeaa7sj.cloudfront.net/s_E03B7F3068651149406121A3CCB672B40D6EDF37D962EC28850BABB322302CCA_1527048473974_1200px-Reverse_proxy_h2g2bob.svg.png)
With nginx, we could achieve this, and even take it further, ever heard of ngrok, maybe you may have, maybe not either way,
> Ngrok is a service that allows you server your localhost application via a domain proxy, exposing it via a public URL.
With the reverse proxy, and setting up a subdomain on your site for such businesses, you can have your own ngrok without the constant change in the domain name and stuff.
To pull this off, the first part is to setup nginx on your server to proxy connections from your specific subdomain or domain (whichever you find convenient) to a specific port on the server.
```
server {
listen 80;
server_name coolsubdomain.mainname.com;
location / {
proxy_pass http://127.0.0.1:5000; #in this case we picked the port 5000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment