2

I currently have one webserver with django/nginx connected to my Arris router DG1670A/TW (loaned by Spectrum IP provider). Perhaps the following info is superfluous for answering my question but here are the configurations anyway, for my current website:

-'firewall->port triggers':
--'outbound port' 80-80 and 'inbound port' 80-80
--'outbound port' 443-443 and 'inbound port' 443-443

-'firewall->virtual servers / port forwarding':
--'outbound port' 80-80 and 'inbound port' 80-80
--'outbound port' 443-443 and 'inbound port' 443-443

Ports 80 and 443 are used for the current website. What is your opinion, advice, answer or alternative solution for 2 servers on one public facing IP: Can I use a 2nd physical server for a 2nd website (different domain name)? It seems to me that default http and https require those ports and setting up a second website would require a user to tediously type 'www.2ndwebsite.com:8080' while nginx is configured for listening on port 8080. Perhaps I just need some new hardware to make this work, like a switch?

  • err? you can have an unlimited of websites running on the same port, that is one purpose a domain has, this is handled by the virtual host file. You can use one domain (siteA.example.com, siteB.example.com or use multiples domains. You can have them all running on 443 or any port you like. Apache2, Nginx and IIS use one port but within the virtual host is where you assign your domains to the location they are stored on disk, that way one domain serves one location and another the other, all done within two shakes of a lamb's tail. – Simon Hayter Feb 9 at 23:19
  • But if you are running two web servers e.g (apache2 and nginx) (not to be confused with multiple domains under one instance) for whatever reason then you would run two domains, one with 80, one with 8080, a user does not need to input :8080 if only one domain is setup for that port because browsers check both 80 and :8080 when accessing any domain. – Simon Hayter Feb 9 at 23:30
  • DNS points both websites to my server's public IP, however, the browser I used (firefox) did not check for 8080. I had to manually append the port to the domain. – Kevin Preston Feb 10 at 23:05
0

The typical way to handle this situation is with a reverse proxy server. You run three web servers:

  1. A back end web server running your first site. This can be on any port of your choosing.
  2. A back end web server running your second site. This can be on any port of your choosing.
  3. Your main web server runs Apache or Nginx with two virtual hosts, one for each host name. The virtual host for each is configured to forward the connection to the correct back end server. This server would run on ports 80 and 443 and you would likely configure it to handle all the SSL.

Your web servers could all run on the same physical machine but on different ports if you want. The important bit is that the reverse proxy is running on the default ports and does the forwarding behind the scenes. This hides ugly port numbers from users.

  • Thanks. I had configured my system for one website. I'm thinking about restarting from scratch to accommodate two sites on the same server within the Django-Nginx framework by following a few tutorials from various online sources. I would rather not buy a third machine for this process. The amount of traffic to my site is little to none so I might take the risk of decommissioning and reconstructing the system. – Kevin Preston Feb 12 at 23:25
  • You can run all three of those servers on one machine if you want. Just make sure that the reverse proxy is the one running on the main ports and the other servers are running on some other ports. – Stephen Ostermiller Feb 13 at 10:13
0

I utilized two virtual environments for each site. Each site had their own nginx configuration files. Each site has separate django 'runserver' ports. It works...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.