2

I have server running different sites and i need to config nginx reverse proxy for these domains, (example1.com, example2.com, test.example1.com), where dp I need to configure the domains in nginx for reverse proxy.

bodgit
  • 4,661
  • 13
  • 26
AsWiN KaRtHiK
  • 29
  • 1
  • 2

1 Answers1

4

multiple server{} blocks and proxy_pass http://origin.server in location blocks.

For example:


server {
  test.example1.com;
  location / {
     proxy_pass http://origin.text.example1.com;
  }
}
server {
  server_name example1.com;
  location / {
     proxy_pass http://origin.example1.com;
  }
}
server {
  server_name example2.com;
  location / {
     proxy_pass http://origin.example2.com;
  }
}

nginx Beginner's Guide and Server names in nginx document will help you.

More complex configurations(including /etc/nginx/sites-enabled/.conf, /etc/nginx/sites-available/.conf) are available, but that relies on your distribution packages.

minish
  • 626
  • 3
  • 10
  • This is also useful if you are running several webservers in docker containers; to direct the different domains to different containers and different IP/port from the main address/80 – Lenne Oct 25 '18 at 08:53