Running a Web Server with Nginx
Deploy Nginx as a reverse proxy on ALPON X5 AI or ALPON X4 through ALPON Cloud: build two example HTTP servers, push them to the Sixfab Container Registry, route traffic to them by hostname, and test from the remote terminal.
Deploy Nginx on ALPON
Host a web server and manage multiple applications on your ALPON X5 AI or ALPON X4 with Nginx. This guide builds two example HTTP servers — a frontend and a backend — deploys them through ALPON Cloud, and puts an Nginx reverse proxy in front of them that routes traffic by hostname.
Build your application images for linux/arm64, push them to your Sixfab Container
Registry, and deploy each one from the Applications → Deploy panel on
ALPON Cloud with a published port (here 31050 and 31060). Then
build an nginx:latest image that carries a default.conf with one
server block per hostname, deploy it with Host Network enabled, and map the
hostnames to 127.0.0.1 in the device’s /etc/hosts to test with curl.
Overview
Nginx is a lightweight web server that also works as a reverse proxy: it accepts requests on one port and forwards them to other services based on the requested hostname or path. Running it as a container on an ALPON X5 AI or ALPON X4 lets you serve several applications from one device under different hostnames or subdomains, all managed through ALPON Cloud.
The two HTTP servers below are provided as examples — swap in your own applications at that stage. The steps are identical on ALPON X4 and ALPON X5 AI.
You need an ALPON X5 AI or ALPON X4 registered on
ALPON Cloud, and Docker with
buildx installed on your build machine to build and push the images. New to container
deployment? Start with
Containerize Apps for ALPON.
-
1
Build and deploy the backend HTTP server
Open a terminal on your computer, create a new file named
Dockerfile, and add the following content:Dockerfile · backend serverFROM nginx:latest RUN echo '<h1>Backend Server</h1>' > /usr/share/nginx/html/index.html
Build the container image for the ALPON’s
arm64architecture:bash · build the backend imagedocker buildx build --platform=linux/arm64 -t backend-server:latest .
Then log in to Sixfab Registry, click + Add Container, and follow the prompts to push the image.
Pushing images to the Sixfab Container RegistryFor the full walkthrough of tagging and pushing an image, see Update Containers from the Sixfab Container Registry.
Once the image is in the registry, open your device in ALPON Cloud, go to the Applications section, and click + Deploy. In the Deploy Container window, use these settings:
Container NameThe application name, e.g.backend-appImageThe backend HTTP server image and tag you pushed to the Sixfab Container Registry.PortsClick + Add More in the Ports section and add the port mapping below.From To 3105080Click + Deploy to launch the backend server on the device.
-
2
Build and deploy the frontend HTTP server
Repeat the same process for the frontend. Create a new
Dockerfilewith the following content:Dockerfile · frontend serverFROM nginx:latest RUN echo '<h1>Frontend Server</h1>' > /usr/share/nginx/html/index.html
Build the image:
bash · build the frontend imagedocker buildx build --platform=linux/arm64 -t frontend-server:latest .
Log in to Sixfab Registry, click + Add Container, and push the image. Then, in the Applications section of your device on ALPON Cloud, click + Deploy and use these settings:
Container NameThe application name, e.g.frontend-appImageThe frontend HTTP server image and tag you pushed to the Sixfab Container Registry.PortsClick + Add More in the Ports section and add the port mapping below.From To 3106080Click + Deploy to launch the frontend server on the device.
-
3
Deploy Nginx as a reverse proxy
Now configure Nginx to route traffic to your applications based on hostnames. Make a new folder (e.g.
nginx-reverse), navigate into it, and add a file nameddefault.confwith this content —api.example.comgoes to the backend on port31050andfrontend.example.comto the frontend on port31060:default.conf · Nginx reverse proxyserver { listen 80; server_name frontend.example.com; location / { proxy_pass http://127.0.0.1:31060; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } server { listen 80; server_name api.example.com; location / { proxy_pass http://127.0.0.1:31050; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }In the same folder, create a
Dockerfilethat copies the config into the image:Dockerfile · Nginx reverse proxyFROM nginx:latest COPY default.conf /etc/nginx/conf.d/default.conf
Build the image:
bash · build the Nginx imagedocker buildx build --platform=linux/arm64 -t nginx-server:latest .
Log in to Sixfab Registry, click + Add Container, and push the image. Then open your device in ALPON Cloud, go to the Applications section, click + Deploy, and use these settings in the Deploy Container window:
Container NameThe application name, e.g.nginx-reverse-proxyImageThe Nginx image and tag you pushed to the Sixfab Container Registry.Enable Host NetworkTurn this on so Nginx listens on port80of the device and can reach the two servers on127.0.0.1.Click + Deploy to start the reverse proxy on the device.
-
4
Update the hosts file
To test locally, map the example domains to the device. In ALPON Cloud, go to your device’s interface, click Open Remote Terminal, and edit the hosts file:
remote terminal · edit the hosts filesudo nano /etc/hosts
Add these lines at the bottom and save (Ctrl+O, Enter, Ctrl+X):
/etc/hosts · example domains127.0.0.1 frontend.example.com 127.0.0.1 api.example.com
-
5
Test the setup
Make sure everything works. In the remote terminal, test the backend:
remote terminal · test the backendcurl http://api.example.com
If you see
<h1>Backend Server</h1>, it’s working. Then test the frontend:remote terminal · test the frontendcurl http://frontend.example.com
If you see
<h1>Frontend Server</h1>, you’re good to go. If both applications respond, the configuration is complete.Reaching the proxy from other devicesTo access
api.example.comorfrontend.example.comfrom another device on your local network, edit that device’s hosts file as in step 4, pointing the names at the ALPON’s IP address instead of127.0.0.1.
- The backend, frontend and Nginx containers all show as running in the Applications section.
curl http://api.example.comon the device returns the backend page.curl http://frontend.example.comon the device returns the frontend page.
You now have a web server on the ALPON fronted by a simple Nginx reverse proxy. Update
default.conf to route additional hostnames or paths to your own applications and redeploy the
Nginx image.
Production image policy: Replace floating
:latestreferences with a reviewed immutable tag or digest, then record the selected version for rollback.
Updated 4 days ago
