Intro
Previously I have found that Docker works well on VF2L even though the server is not very powerful. VF2L doesn't include Docker-Compose and it was educational for me to use command line tools. There are limited pre-packaged images available for risc-v, but this isn't an issue as Alpine, Debian or Ubuntu can be used as a basis for installing software packages.
VF2L is convenient to use as a testing ground and I decided to try out nginx here even though I could use Docker on RPI or Windows where more docker capabilities are available (compose, desktop, OMV etc).
Proxy Servers
I don't have a good understanding of Proxy Servers. Originally they were used so that a number of local clients could share an Internet IP address, more recently this has been replace by NAT (Network Address Translation) but proxy servers are still used by some to cache pages, filter available sites and for authentication. This type of proxy is known as a forward proxy server. In contrast reverse proxy servers accept requests from the Internet and pass them to appropriate web / application servers for processing. They protect internal servers from malicious users and provide SSL certificates and load balancing. The title "proxy server" is used for either forward or reverse proxies, which can be confusing.
Nginx
Nginx is the leading proxy server used currently. It provides a web server, reverse proxy, load balancing and caching. I noticed that it has an official Docker riscv64 image and decided to try it out on VF2L.
It was as simple as typing a docker run command to download the software and spin up a container. I can then immediately access the nginx placeholder home page. It only took a minute!
The nginx container runs on a stripped down debian image (126MB) and I needed to install "nano" so that I could create my own test home page in /usr/share/nginx/html/index.html.
After a little experimentation I configured a more useful container. This has two volumes "html" for webpages and "conf.d" for the nginx configuration file. As these volumes are provided from VF2L I can conveniently edit the files on them outside the container then reload nginx in the container to update the configuration.I also prefer to alpine linux (52MB) as a base over Debian for Docker servers.
As VF2L is a test server I allocated port 80 to be available for the web server.
Nginx web server configuration
I started by creating an nginx web server. This is very simple. The default.conf file simply says that the server should listen on port 80 and the home page is to be found at /usr/share/nginx/html.In my browser I enter the VF2L ip address and the container returns the ...nginx/html/index.html webpage from the server.
I added a couple of extra locations. This provides the ability to setup separate web page mappings.
The URI http://192.168.0.25/second.html maps to ...nginx/html/second.html.http://192.168.0.25/third/ maps to ...nginx/html/third/index.html.
I found it a little confusing that nginx adds in the location (e.g. /third/ ) to URI but this is useful.
nginx proxy server
External Access
Now I can enter my external ip address and add "/pi/". My router sends the request to VF2L which looks at "/pi/" and forwards it to //PI41 which returns the web page html/pi/index.html.