Run several websites using a single IP address.
Run several websites using a single IP address.
Hello everyone, I own my own domain with a reliable internet connection and a fixed public IP. My domain has proper A-entries for both WWW and MAIL (mail.mydomain.com), along with MX records for email. I’m wondering if it’s possible to run several HTTPS sites using the same IP address. My current setup already works with a Let’s Encrypt certificate, but when I visit mail.mydomain.com it redirects me to my website instead. How can I set up my network so that visiting mail.mydomain.com takes me directly to the mail server? The website and the mail server are on separate servers. Any guidance would be greatly appreciated. This is really confusing for me.
Change the backend port configuration for better connectivity.
The solution to your query is virtual hosts. You can configure virtual hosts in your Apache/nginx settings to direct mydomain.com to one directory and myotherdomain.com to another. This explains how shared hosting operates—using a single IP address for many websites. If you're not comfortable changing configuration files yourself, you can rely on hosting services like ISPconfig, Plesk, or cPanel, which handle these tasks automatically. ISPconfig is the open-source, free alternative to the other two options.
It's a solid option, though it only functions properly if your servers use Apache or Nginx. For completeness, I should note Haproxy: it acts as a proxy, allowing multiple HTTP/HTTPS services to share the same IP address and deliver different content based on the domain accessed. It works regardless of whether they run under Apache or Nginx. I personally use it to manage various services myself.
I manage multiple websites on my server with Lighttpd, though I suggest using Apache. I currently rely on one certificate that authorizes all sites, as a single cert can cover several domain names. I also use Let's Encrypt for additional security. There are alternative methods involving SNI, where you sign a unique cert for each domain separately and set the certificate paths individually on the server. Each site has its dedicated folder, so when a user visits a domain like google.com, the server searches for that folder and serves the corresponding website. If the folder isn't found, it informs the user they're not on the right page. A bit more technical—if you can't modify server settings and your sites use a controller architecture (like MVC), you can programmatically identify the requested host and run the relevant controller for that application.
IIS or any web server that works well. If all sites are on the same machine with identical IP addresses, you don't require a reverse proxy such as HAProxy or Nginx.