Magento 2.4.3 duplicate upstream “fastcgi_backend”

I’m setting up a web host for my Magento 2.4.3 site. So basically I have 2 glasses shops namely Prescription Safety Glasses and Prescription Sports Sunglasses. Since these 2 optical stores are using the same code and DataBase  I set up the web host in NGINX, Ubuntu 21.0.4, php7.4. The only differences are their server_name,  when I try to restart my Nginx I get the emerg duplicate upstream “fastcgi_backend” error.

Here is one of my vhost .conf code:

upstream fastcgi_backend {
server unix:/tmp/php-cgi.sock;
}
server
{
listen 80;
server_name www.bestpriceglasses.com bestpriceglasses.com;
set $MAGE_ROOT /web/webhosting/www.bestpriceglasses.com;
include /web/webhosting/www.bestpriceglasses.com/nginx.conf.sample;

#error_page 404 /404.html;

# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

include enable-php.conf;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

location ~ /.well-known {
allow all;
}

location ~ /\.
{
deny all;
}

access_log off;
}

server
{
listen 443 ssl http2;
server_name www.bestpriceglasses.com bestpriceglasses.com;
set $MAGE_ROOT /web/webhosting/www.bestpriceglasses.com;
include /web/webhosting/www.bestpriceglasses.com/nginx.conf.sample;

ssl_certificate /**************;

#error_page 404 /404.html;

# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

include enable-php.conf;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

location ~ /.well-known {
allow all;
}

location ~ /\.
{
deny all;
}

access_log off;
}

 

Consider fastcgi_backend as just any variable name. Since I have two projects Nginx reads both the conf files and finds that fastcgi_backend is used multiple times. If we are running both the projects with the same fpm socket then we can remove either one, but if you have multiple PHP versions set up and hence are using a different fpm socket, change fastcgi_backend to any name in one of the projects. Make sure that we use the changed name in our nginx. conf.

That is to say, we only keep one copy of the following code:
upstream fastcgi_backend {
server unix:/tmp/php-cgi.sock;
}

And remove these code for the other added on domain names, or:

# upstream fastcgi_backend {
# server unix:/tmp/php-cgi.sock;
# }