nginx [emerg] duplicate listen options for 0.0.0.0:443 error

Time:2022-9-23

Submit a system to the test server today, the PHP version of the test server is 7.2, and the laravel 8.0 should be above 7.3. There are too many projects in the test server, and there are many very old projects. It is not easy to upgrade easily, so I plan to put it into a less important project. On the machine, they share the same machine, and that php version is relatively high

The operation is to directly establish the publishing system and update the code to the new server

Then parse the domain name, copy an nginx configuration, modify the domain name, path and log, when restarting, nginx for 0.0.0.0:443 error, nginx: [emerg] duplicate listen options for 0.0.0.0:443 in /nginx/conf.d /xxx.com.conf:3

Check it out:
It is probably the repeated option, so where is it repeated?

default_server, the first site for direct copy, and default_server when the second is modified

Obviously, there can only be one default server

The default_server parameter, if present, will make the server the default server for the specified address:port pair.

Then also said that the listen instruction can have several additional parameters specific to socket-related system calls. They can be specified in any listen directive, but can only be specified once for a given address:port pair.

Therefore, the default of the second station should be deleted, and the problem will be solved after trying

Refer to the original address:https://github.com/alibaba/te…

Reference example:

First

server {
    listen 443 ssl http2 fastopen=3;
    server_name  www.example.me;

It can remain unchanged or the insurance can add a default and change it to

server {
    listen 443 default ssl http2 fastopen=3;
    server_name  www.example.me;

All the following listen 443 ssl delete the ssl part, just listen 443

server {
    listen 443;

Reference two original address:http://mailman.nginx.org/pipe…

Socket can't be in ssl mode for some servers and in non-ssl for 
others, so there is no need to specify "ssl" argument for 
non-default servers.  I.e. this will work with ssl in both 
servers:

server {
    listen 443 default ssl;
    ...
}

server {
    listen 443;
    ...
}

In your first configuration nginx was able to detect that you used 
meaningless "ssl" argument in second server and complained.  In 
second configuration it wasn't able to detect meaningless "ssl 
on;" statement.  This is the only difference.

Maxim Dounin