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.

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.

1
  • 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 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.