0

Working as a sys admin for multiple departments, and due to constrained resources, I'm considering deploying nginx and httpd in one server. (Due to developer requirements, using Docker isn't an option)

Server has apache installed. How to install nginx alongside it?

It seems this was discussed a while ago, is this still the case?

and I'm doing reverse so,

$ cat /etc/nginx/sites-available/default
##

    server {
        listen 8000;

        server_name log-dashboard-03;

        auth_basic "Restricted Access";
        auth_basic_user_file /etc/nginx/htpasswd.users;

        location / {
            proxy_pass http://localhost:5601;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;        
        }
    }

Can I run Apache & Nginx on the same server, on the same port but bound to different IPs? variations still work? (No one wants to switch to the other side, as in from httpd to nginx or vice versa and only one fully routable internal ip). nginx is there first, but I wanted opinion before dumping another httpd proxy here. (If you wonder why listen on 80 and 8000 only, WSAs only allow certain ports 80, 8000 and 5000. Also the applications are designed for now to be only accessible by localhost and not remote)

httpd to-be:

$cat /etc/httpd/conf/httpd.conf
DocumentRoot /var/www/html

ProxyPass / http://localhost:8080/ nocanon

ProxyPassReverse / http://localhost:8080/
ProxyRequests Off

ProxyPreserveHost On

<Proxy http://localhost:8080/*>

Order deny,allow

Allow from all

</Proxy>

1 Answer 1

0

You can't run two applications / services on the same port. You can run nginx on another port, it's trivially easy, just set up your server on a different port from Apache, pretty much like you've done above already.

If you want to run two domains on different servers on the same port you can have nginx listen on whatever port you want then proxy_pass whatever you need to through to Apache.

How about you tell us what you're trying to achieve, rather than tell us how you're trying to do it? That will get you better advice. Explain it like you're explaining it to an intelligent child, update your original question then comment so I get notified. If I can add more I'll up date my answer.

1
  • You answered so now I can try deploying over the weekend. Didn't want to debug during weekdays to have downtime in case there are problems. Basically, dev 1 wrote an app that talks via 8080 and dev 2 wrote app that talks via 5106. So poorServer:8000 and pooServer. (They are some host hardware analysis so it can't be on VMs/Docker). Also lovely Cisco WSAs due to company policy so have to put 5106 through 8080, etc. And we have to literally beg the IT to get another internally routable ip, hence this misery. (Aware of one port per ip). Thanks again.
    – user192756
    Feb 13, 2016 at 4:55

You must log in to answer this question.