Putting local web server online without opening ports
Solved
briocheOchoco
Posted messages
7
Status
Member
-
avion-f16 Posted messages 19182 Registration date Status Contributor Last intervention -
avion-f16 Posted messages 19182 Registration date Status Contributor Last intervention -
Hello, unable to modify the settings of my internet box (Orange), I cannot redirect the ports.
I have an old PC at home running Ubuntu Server that allows me to host my site locally, and I would like to make it accessible to the public internet. For example, I want to be able to access my site from an external PC (or my phone on 4G) by typing my public IP address (which is static since I have a pro box from Orange) but without opening the ports on the box.
I would like a solution that does not change the address used to access it.
like not something like monsite.trucmuche.fr
Best regards, thank you for your help.
I have an old PC at home running Ubuntu Server that allows me to host my site locally, and I would like to make it accessible to the public internet. For example, I want to be able to access my site from an external PC (or my phone on 4G) by typing my public IP address (which is static since I have a pro box from Orange) but without opening the ports on the box.
I would like a solution that does not change the address used to access it.
like not something like monsite.trucmuche.fr
Best regards, thank you for your help.
3 answers
-
Hi
What model is the box? Because without redirecting the ports, I don't see a solution.
--
Light a fire for someone and they will be warm for the rest of the day. Set a man on fire and he will be warm for the rest of his life. -Terry Pratchett- -
Hello,
If you want direct access with your static IPv4 address, there's no choice; you will necessarily have to create a port forwarding at the level of the box. I do not see how you could expect to access your server without port forwarding via http://1.2.3.4/ knowing that 1.2.3.4 is routed to your box and not the server.
Moreover, most boxes offer the ability to create port forwarding, especially with a "pro" offer.
However, in cases where port forwarding is not possible for various reasons:
- Access to the router/box administration not authorized (shared internet access in housing...).
- No public IP routed to the box (CG-NAT)
- ...
You will need to go through an intermediary server that will link visitors to the server at home. The local server will establish an outgoing connection (VPN tunnel, SSH, proprietary protocol, ...) to the remote server using appropriate software.
-> This implies that the visitor will access not the box's IPv4, but that of the remote server. Whether with the IP or a domain name resolved to this IP.
Most of these services are reverse HTTP(S) proxies and will do the routing¹ to one server or another based on the name, thus requiring the use of a domain or subdomain in order not to have to dedicate an IP per user.
Not using a name (domain/subdomain) would mean that the entire IP, or at least the IP + port pair (80/443) will be fully redirected to your server. This is entirely possible but an IP dedicated comes at a cost; these services are no longer free.
In the case of an HTTPS proxy, one must be aware that TLS encryption is not between the visitor <-> local server, but between visitor <-> remote server. In several cases, the connection remote server <-> local server is not encrypted, many skip this part, but it is entirely possible to have visitor <-> remote server encryption combined with remote server <-> local server encryption. However, it will not be "E2EE" encryption as the intermediary server can read the exchanges. To keep in mind depending on the level of confidentiality/trust.
Among these services:
https://ngrok.com/
https://www.cloudflare.com/products/tunnel/
or a fairly exhaustive list of commercial or free SaaS solutions, or solutions that can be self-hosted (you will still need an intermediary server like a VPS at €5):
https://github.com/anderspitman/awesome-tunneling
Being in the same situation, I rent a €5 VPS that acts as a VPN server. My server connects to it as a VPN client. The VPS therefore becomes a "remote NAT" router between its WAN (Internet) and the virtual local network created by the VPN software. Since it is a remote router, I then configure a port forwarding from its public IP to the local IP (in the VPN network) of my server.
Otherwise, with IPv6, these NAT/port forwarding issues no longer exist.
¹ The word routing is used here to refer to the act of displaying one site or another based on the name, in the same way as a VirtualHost under Apache/Nginx. It is not IP packet routing as performed by a router. -
Hello,
Thank you for your response,
Since the post of my message, I can now access my box's settings,
Now I can redirect port 80 to my Ubuntu server, but my second question is:
Should I configure Apache in a particular way to be able to access my server from the outside internet?
And
Should I open port 80 first and then configure Apache, or do the opposite?
Best regards, Brioche.-
> Should I configure Apache in a specific way to access my server from the outside internet?
No special configuration is required; the server will handle requests from local or external visitors in the same way. If you can access it from your local network, then chances are that the Apache configuration is already correct to allow access from the outside as well.
> Should I open port 80 first and then configure Apache, or do the opposite?
There is no preferred order, but both actions are necessary.
I see you are focusing on port 80, but don't forget the importance of HTTPS!
Especially if you plan to host services like Nextcloud or others, which involve transferring sensitive data (files, credentials, ...).
To learn the basics of networks and understand these NAT (SNAT / DNAT) mechanisms in just 1 hour, I recommend this video: https://www.youtube.com/watch?v=mgEMGoFIots
-