Upgrade Broke nginx Configuration? -- php-handler error?

Hello,
Last night I upgraded to 20.0.11 (I believe?) via web browser.
At the end the nextcloud upgrade returned successful.

Logged in to the server via ssh.
I then ran all updates in the server.
I then rebooted the server.
Server is Debian10 Buster with all its updates installed.

After reboot, the nextcloud installation website is down.

Logged into the server via ssh:
Running $systemctl status nginx
Returns a “Failed to start nginx”.
The nginx logs show: no port in upstream “php-handler” in /etc/nginx/conf.d/nextcloud.conf:76

That line number-76 has one of the nginx stanzas, and the line reads:
fastcgi_pass php-handler;

Any idea what I can do to fix this?
I mean… do I have to install the php-handler?

Thank you everyone for your help.

Adding some more information…
I tested the nginx configuration with the following lines, and got a reply:

ajFunnellocalhost:~$ sudo nginx -c /etc/nginx/conf.d/nextcloud.conf -t
[sudo] password for aj:
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/nextcloud.conf:1
nginx: configuration file /etc/nginx/conf.d/nextcloud.conf test failed

And for reference, below attached the nginx configuration located in /etc/nginx/conf.d/nextcloud.conf

server {
        listen 80 default_server;
        listen [::]:80; server_name nc.MYDOMAIN.com;
        location /.well-known/acme-challenge {
                root /var/www/letsencrypt;
                default_type "text/plain";
                try_files $uri =404;
        }
        location / {
                return 301 https://$server_name:443;
        }
}

server {
        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2;      server_name nc.MYDOMAIN.com;
        root /var/www/nextcloud;
        access_log /var/log/nginx/nextcloud.access.log main;
        error_log /var/log/nginx/nextcloud.error.log warn;

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location = /.well-known/carddav {
                return 301 $scheme://$host:443/remote.php/dav;
        }
        location = /.well-known/caldav {
                return 301 $scheme://$host:443/remote.php/dav;
        }

        location ^~ /loleaflet {
                proxy_pass https://localhost:9980;
                proxy_set_header Host $http_host;
        }

        location ^~ /hosting/discovery {
                proxy_pass https://localhost:9980;
                proxy_set_header Host $http_host;
        }
        location ^~ /lool {
                proxy_pass https://localhost:9980;
                proxy_set_header Host $http_host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }


    location ^~ /hosting/capabilities {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }


        client_max_body_size 10240M;

        location / {
                rewrite ^ /index.php$uri;
        }
        location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
                deny all;
        }
        location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
                deny all;
        }
        location ~* \.(?:flv|mp4|mov|m4a)$ {
                mp4;
                mp4_buffer_size 5m;
                mp4_max_buffer_size 10m;
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                include fastcgi_params;
                include /etc/nginx/conf.d/php_optimization.conf;
                fastcgi_pass php-handler;
                fastcgi_param HTTPS on;
        }
        location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                include fastcgi_params;
                include /etc/nginx/conf.d/php_optimization.conf;
                fastcgi_pass php-handler;
                fastcgi_param HTTPS on;
        }
        location ~ ^/(?:updater|ocs-provider)(?:$|/) {
                try_files $uri/ =404;
                index index.php;
        }
        location ~ \.(?:css|js|woff|svg|gif)$ {
                try_files $uri /index.php$uri$is_args$args;
                add_header Cache-Control "public, max-age=15778463";
                access_log off;
                expires 30d;
        }
        location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
                try_files $uri /index.php$uri$is_args$args;
                access_log off;
                expires 30d;
        }
}

Pardon, the above is wrong.
On the above post, I tested directly the nginx configuration for nextcloud.

You can’t do what I did: $nginx -t nextcloud.conf

You have to test the parent (main?) configuration of nginx via:
$nginx -c nginx.conf -t

That parent (main?) configuration file will include (pull in) the nextcloud.conf.


Still, when I test the nginx.conf it blows up on the same line when it hits the nextcloud.conf:

nginx: [emerg] no port in upstream “php-handler” in /etc/nginx/conf.d/nextcloud.conf:76

It’s fixed now… at least with a band-aid.

What I ended up doing was:
In a Nextcloud installation, nginx has its default nginx.conf.
That nginx.conf includes (imports) the nextcloud.conf.

Now, the nextcloud.conf includes (imports) a php_??.conf.
That’s the error.
When the file nextcloud.conf was going to use

fastcgi_pass php-handler;

it would blow up.

I was able to figure out (I still figure out badly) that what it wanted was:

fastcgi_pass /run/php/php7.4_fpm.sock

From my bad understanding of how nginx and php and fpm work together:
when php (or fpm??) is started up, it will open that unix socket (which is the file php7.4_fpm.sock).

Now, our nextcloud.conf for nginx was looking for a variable (I think!).
Yet I hardcoded the variable with the line:

fastcgi_pass /run/php/php7.4_fpm.sock
– This line above goes inside the /etc/nginx/conf.d/nextcloud.conf file.

And from where the heck did I acquire that unix socket (the .sock file)?

From

/etc/php/7.4/pool.d/www.conf

Inside that file, there is a line that is

listen

And that’s the socket.

So once that was done, nginx was able to start

systemctl start nginx

And now everything is working.

Have a good one.