Dr. Greg Bernstein
Updated November 13th, 2021
A forward proxy is an Internet-facing proxy used to retrieve data from a wide range of sources. Used for monitoring, content filtering, bypassing filters and censorship, caching, and more.
A reverse proxy is an internal-facing proxy used as a front-end to control access to servers on a private network. Common tasks include: load-balancing, authentication, decryption or caching.
NGINX: Performance Tips for Node.js Apps – read this
Tip 1 – Implement a Reverse Proxy Server
Node.js and Apache2 – Using the Apache2 server as a reverse proxy for Node.js
Reverse proxy forward HTTP requests to different machines/processes based on parts of the URL
https://classroom.grotto-networking.com
NGINX configuration file (partial)
server {
server_name classroom.grotto-networking.com;
location / {
proxy_pass http://localhost:21146; # Internal port for CSOARS
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# More configuration stuff such as ports and
# HTTPS stuff
}
Apache2 configuration file (partial)
<Location "/student39/node" >
ProxyPreserveHost On
ProxyPass http://127.0.0.1:3039
ProxyPassReverse http://127.0.0.1:3039
</Location>
<Location "/student40/node" >
ProxyPreserveHost On
ProxyPass http://127.0.0.1:3040
ProxyPassReverse http://127.0.0.1:3040
</Location>
We will want to use proxy functionality in development:
We will write our own application server to give and process data from our web app.
We will combine our bundler (Parcel.js) with and Express.js server and additional middleware.
Need Specifics on Addresses and Ports
.proxyrc.json
FileFrom Parcel: API-proxy
{
"/api": {
"target": "http://localhost:8000/",
"pathRewrite": {
"^/api": ""
}
}
}
"This example would cause http://localhost:1234/api/endpoint
to be proxied to http://localhost:8000/endpoint
.
.proxyrc.json
File{
"/members": {
"target": "http://localhost:5001"
}
}
This would map the relative request of /members
to http://loalhost:5001/members
.