How to Configure Nginx to be gateway to serve Multiple Websites

I have a domain name using centos7.
I have subdomains where differents applications run. For example:

app1, app2, app3 and nginx are four differents servers.
app1, app2 and app3 are accessible from the internet.

What I want is to access all my applications from the internet via For example: → to serve → to serve → to serve

To achieve that, I have configured the reverse proxy in the server to access app1 app2 app3 via the server.
I modified the nginx.conf file of the server as follows:




location /app1{
proxy_set_header host $proxy_host;
proxy_pass; }

location /app2{
proxy_set_header host $proxy_host;
proxy_pass; }

location /app3{
proxy_set_header host $proxy_host;
proxy_pass; }


but I can’t access apps through the server

I cannot find a Way to achieve this after many try… I get error like server is not accessible

Can you help me with the different steps to follow to achieve this?

Hi Android_androod,

Welcome to our forums.

At first glance of your configuration parts there is a typo:

Which should be server_name I suppose. I would suggest you always validate your nginx configuration with something like:

nginx -c /etc/nginx/nginx.conf -t

And do so before applying the changes. The error message suggests that your nginx server can’t run, which can be caused by a simple typo in the configuration. I also suggest you setup reverse proxy to a single application first, and add more after that works flawlessly.

You may want to check our guide on nginx reverse proxy for reference.