Is it possible to make Nginx listen to different ports?

Yes, it is.

What you probably want is multiple “server” stanzas, each with a different port, but possibly (probably?) the same server_name, serving the “different” content appropriately within each one, maybe with a different document root in each server.

Full documentation is here:
http://nginx.org/en/docs/http/server_names.html

Example:

server {
    listen       80;
    server_name  example.org  www.example.org;
    root         /var/www/port80/
}

server {
    listen       81;
    server_name  example.org  www.example.org;
    root         /var/www/port81/
}

Leave a Comment