Setup for forward proxy
info
Use the forward proxy to route outbound traffic to desired endpoints, useful for blocking outbound traffic to undesirable sites
- Locate the nginx.conf file
- Comment out any other server blocks and the following commands
- nginx configuration
server { location / { # To turn this into a forward proxy, uncomment the line below (or the one after) - SAW #proxy_pass http://localhost:8085/; # If you have a webserver running on IP:port via docker try the command below - SAW proxy_pass http://192.168.99.100:8888/; } # ~ character indicates that a regular expression will follow # The regex below matches on any image file with the extensions gif, jpg or png location ~ \.(gif|jpg|png)$ { root /pf/nginx/sels-sandpit/dataa/images; } } # Selvyn's proxy server setup # Essentially this sets up a nginx listener on 8085 and distributes content from "/pf/nginx/sels-sandpit/data/up1" for base url pattern match server { listen 8085; root /pf/nginx/sels-sandpit/data/up1; location / { } }
Restart nginx
- nginx -s reload
Interesting side effect on tomcat
None of the images of the web app are displayed. So I looked again at the config file and saw that I had entered the following script block
location ~ \.(gif|jpg|png)$ { root /pf/nginx/sels-sandpit/data/images; }
Essentially, in an outgoing query from this machine to localhost, this block looks for any reference for gif, jpg and png file (irrespective of whee they sit in the url after the root. It then directs nginx to look for such images in the /pf/nginx/sels-sandpit/data/images folder. I did a little digging and found the image required on the home page is tomcat.png. So I copied it to /pf/nginx/sels-sandpit/data/images refreshed the page and the image appeared. I then navigated to another page, and the tomcat logo wasn't showing again. Did a little digging and found that it as looking for tomcat.gif this time. So copied that image to the folder /pf/nginx/sels-sandpit/data/images. Did a refresh, it still didn't work, so what's going on mmm?