How to access the development HTTP server on Oracle Cloud with an SSH tunnel#
When managing a static site using Sphinx + ablog on an Ubuntu server on Oracle Cloud, you may want to check the display locally before git push. Even in situations where direct access via HTTP from the outside is not possible, you can check the site under development by using an SSH tunnel.
In this article, we will introduce how to temporarily start an HTTP server on an Ubuntu server set up on an Oracle Cloud Free Tier instance, and connect and check it from your home browser using an SSH tunnel.
background#
Servers run on Always Free tier in Oracle Cloud
Maintaining documentation and blog articles using Sphinx + ablog
I want to check
_build/htmlaftermake htmlin a browser.However, the development port (e.g. 8000) is not exposed externally and cannot be accessed directly.
How to achieve: SSH tunnel#
If you have an SSH connection, you can use SSH’s port forwarding (local forwarding) feature to make localhost:8000 on your server appear to be localhost:8000 at home.
1. Start a simple HTTP server on the server side#
cd ~/my-site/_build/html
python3 -m http.server 8000
Verify that curl http://localhost:8000 responds correctly from within the server.
2. Create an SSH tunnel on the client side (Windows)#
Run the following in PowerShell or Command Prompt:
ssh -i path/to/private_key -L 8000:localhost:8000 ubuntu@<サーバのグローバルIP> -N
-i: Specify private key-L: Forward local port 8000 to server localhost:8000-N: Do not execute command, just connect
If successful, you can check the HTML output during development by visiting http://localhost:8000 in your browser.
remarks#
SSH tunnel is valid only while connected. Closing the terminal will disconnect you
Similar settings can be made with PuTTY (add tunnel via GUI)
Can be used without changing Oracle Cloud security list or UFW settings
summary#
Using this method, we were able to create a way to visually check the Sphinx + ablog site before it was pushed to Git.
サーバ:Oracle Cloud Ubuntu (Free Tier)
確認方法:python3 -m http.server 8000
アクセス手段:ssh -L 8000:localhost:8000 ... -N
ブラウザ確認:localhost:8000
It looks like it will continue to be used in the future as a way to safely build and check a development environment without disclosing it to the outside world.
Note
I tried setting up to expose port 8001 externally on the Oracle Cloud side (adjusting the security list and UFW), but I was unable to establish a connection and was unable to identify the cause. I gave up because hosting was not my goal.
Article information
- Post date:
2025-05-12
- author:
Mr. Takagi