Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help: How to configure NGINX to listen multiple ports? (cPanel)
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Help: How to configure NGINX to listen multiple ports? (cPanel)

deployvmdeployvm Member, Host Rep
edited April 2015 in Help

Is there a possibility to configure NGINX (nginx admin module) for every vhost in cPanel to listen on both port 80 and port 8880? The same vhost configuration/site that appears on port 80 should be accessible on port 8880 also. I do not need multiple instances of a vhost on different ports.

Original configuration excerpt:

def writeconfded(user, domain, docroot, passedip, alias):
        user = user
        domain = domain
        passedip = passedip
        dedipvhost = """server {
          error_log /var/log/nginx/vhost-error_log warn;
          listen %s:80;
          listen [::]:80;
          server_name %s %s %s;

2nd block for shared IPs:

def writeconfshared(user,domain,docroot,passedip, alias):
        sharedipvhost = """server {
          error_log /var/log/nginx/vhost-error_log warn;
          listen %s:80;
          listen [::]:80;
          server_name %s %s;

The default vhost template is located at: /scripts/createvhosts.py.
The current listen configuration port is:

listen %s:80;
listen [::]:80;

I have added:

listen %s:8088;
listen [::]:8088;

to the template but after saving the template and restarting nginx, I get a gateway error. No error shows up in the error log or upon restart of the service. Port 8088 is not even accessible (not a firewall issue/ nginx simply hasn't binded it.)

Please let me know on how this could be configured!

The reason for this is due to complications on port 80, and port 8880 (or other) can be an alternative.

Thanks.

Comments

  • deployvmdeployvm Member, Host Rep
    edited April 2015

    I've figured a quick trick is to do this via iptables by using:

    iptables -A PREROUTING -t nat -p tcp --dport 8880 -j REDIRECT --to-port 80

    by forwarding all received requests from port 8880 to port 80.

    but is there a nginx binding/listen method?

  • edited April 2015

    Try

    listen 80 default_server;

    listen 8080;

Sign In or Register to comment.