S
S
source20032016-10-15 00:26:27
Nginx
source2003, 2016-10-15 00:26:27

Forwarding domains to different ports in nginx?

How to direct domains to different ports in nginx or cloudflare?
For example, two applications are running on the same server, one on port 8080, the other on port 1337, you need nginx or CF to redirect the example.com domain to SERVER_IP:8080, and example.net to SERVER_IP:1337.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-10-15
@source2003

In nginx, something like this:

server {
    listen 80;
    server_name example.com;
    location / {
        proxy_pass http://SERVER_IP:8080;
    }
}

server {
    listen 80;
    server_name example.net;
    location / {
        proxy_pass http://SERVER_IP:1337;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question