Multiple proxy_pass destination for multiple domain name

What I want to do is like this,

Change the destination of proxy depending on domain name.

However it shows the error

a duplicate default server for 0.0.0.0:8090 in /etc/nginx/sites-enabled/default:7

server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name exmaple.com;

    location / {
        proxy_pass  http://127.0.0.1:8021/;
        include     /var/www/html/exmaple/current/uwsgi_params;
    }

}

server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name exmaple2.com;

    location / {
        proxy_pass  http://127.0.0.1:8022/;
        include     /var/www/html/exmaple2/current/uwsgi_params;
    }

}

I should not duplicate the server delective.

However how can I use multiple proxy_pass.

remove default_server from the first or the second server config

Back to Top