itdxer
itdxer

Reputation: 1256

Nginx: hide port for different domains on single server

I have 4 domains and 1 server. I install nginx and put 4 landing pages.

Example for one of them:

server {
   listen 2000;
   root /path/to;
   index index.html;
   server_name 1.1.1.1;
   location / {
       allow all;
   }
}

How I can redirect my domains for one of this landing pages? for example, when I open page http://mydomain.com i get landing page from address 1.1.1.1:2000

Upvotes: 0

Views: 335

Answers (1)

Tan Hong Tat
Tan Hong Tat

Reputation: 6864

Try this. This will listen on different ports. So you have to access it via example1000.com:1000. Or you could change all listen to 80, and access it via example1000.com, example2000.com, etc,.

server {  
  listen 1000;

  # The host name to respond to
  server_name example1000.com;

  # Path for static files
  root /sites/example1000.com/public;

  # Index
  index index.html
}

server {  
  listen 2000;

  # The host name to respond to
  server_name example2000.com;

  # Path for static files
  root /sites/example2000.com/public;

  # Index
  index index.html
}

Upvotes: 1

Related Questions