.. _http server: Run an HTTP Server in a VM ========================== This guide shows how to create a Debian virtual machine, install nginx, and expose its HTTP port to the host so you can reach it from a browser or curl. Create the Virtual Machine -------------------------- Create a VM with port forwarding so that host port 8080 maps to guest port 80: .. code-block:: $ cubic create webserver --image debian:trixie --port 8080:80 Start the Virtual Machine -------------------------- .. code-block:: $ cubic start webserver Install nginx ------------- Connect to the VM over SSH and install nginx: .. code-block:: $ cubic ssh webserver $ sudo apt update && sudo apt install -y nginx nginx starts automatically after installation and listens on port 80 inside the VM. Verify from the Host -------------------- Open a new terminal on the host and send a request to port 8080: .. code-block:: $ curl http://localhost:8080