Welcome! Log In Create A New Profile

Advanced

Problem with to multiple virtual hosts

Posted by auto 
auto
Problem with to multiple virtual hosts
May 08, 2018 07:50AM
We use nginx for Hosting multiple hosts. We have haves mixes, some sites are
only available at http:// and other sites are available with https://

We create a new config-file for every virtual hosts (domain) if there is a
new customer with a new Homepage. All works correctly.

Today we create 2 new config-files on the nginx, copy the file to
sites-enabled and make a nginx reload.

Now, no sites works again. But there was no error after the nginx reload.

In the Browser we get the error that the Site is not available. And we get
this error at all Sites.

In the nginx error.log we get the message *2948... no "ssl_certificate" is
defined in server listening on SSL port while SSL handshaking, client:
178...., server 0.0.0.0:443

In the Log-Files are many of these messages, i think ~20 lines of this.

The Virtual-Host config File we create look like:

server {
listen 80;
server_name example.de;
return 301 http://www.$http_host$request_uri;
}
server {
listen 80;
server_name *.example.de;
location / {
access_log off;
proxy_pass http://example.test.de;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwareded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_sestheader Connection "upgrade";
}
}

We get the error only if we create a new virtual-host file in the
sites-enabled. if we copy the code into a exisiting virtual host file it
works correctly and all other sites works again.

Any Ideas why it doesn't work if we create a new file? We deleted the new
file, create it again but always get the same effect with the error Message
in the error-log file.

I don't know if its important but we have 196 Files in the sites-enabled
directory. If we create a new one the error come again, if we delete the
file and write (copy&paste) the same code into a existing file, it works
correctly?!

We don't think that is a ssl error, we think that the count of files are the
problem?!

We want to create always a new virtual-host config-file for each customer
and don't edit add the config to a existing file.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279708,279708#msg-279708

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Francis Daly
Re: Problem with to multiple virtual hosts
May 09, 2018 10:20PM
On Tue, May 08, 2018 at 01:46:07AM -0400, auto wrote:

Hi there,

> Today we create 2 new config-files on the nginx, copy the file to
> sites-enabled and make a nginx reload.
>
> Now, no sites works again. But there was no error after the nginx reload.
>
> In the Browser we get the error that the Site is not available. And we get
> this error at all Sites.
>
> In the nginx error.log we get the message *2948... no "ssl_certificate" is
> defined in server listening on SSL port while SSL handshaking, client:
> 178...., server 0.0.0.0:443

The error message refers to something to do with ssl.

The example config files you show do not mention ssl.

Does the actual config that you are writing to the new file that leads
to the failure, refer to ssl at all?

Is the new file name alphabetically first in the list of files?

Do you have the word "default_server" on any "listen" line in any file?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
auto
Re: Problem with to multiple virtual hosts
May 11, 2018 10:20AM
@Francis: so this is the big question, we only want to include 2 new sites
that are only available without ssl. so we included the files without the
ssl part. but if we include it, we get a ssl error?!
no the new files are anywhere between the other files, these files are not
the first files in the alphabetically list.
at the moment i don't now if we have the word "default_server" in any file
of the virtual-host files.
there are 196 files in the sites-enabled directory, maybe i have a look in
the next days if there is the word "default_server" anywhere.

a few days ago we created a additionally directory for the virtual-host
files and insert there the new virtual-host files.
We included the new directory in the config-file of the nginx.conf, and now
it works!
We don't know why, we think that the count of the files in the "normal"
sites-enabled directory are the problem or so?!
With this solution, it works correctly without any errors.
These files are the same files we had included the first the in the "normal"
sites-enabled directory.

We think that the count of the 195 virtual-host files are the problem in one
directory?! but we don't know it, we only believe it.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279708,279756#msg-279756

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Francis Daly
Re: Problem with to multiple virtual hosts
May 14, 2018 01:20AM
Hi there,

it sounds like you have found a workaround for your production system,
so that it a good thing.

The probably-not-satisfactory but maybe-adequate thing is for you to
create a new directory whenever the current directory has (say) 100 files,
and put new files into the new directory.

If you are willing to do some more testing, perhaps the problem can be
identified and the "proper" solution designed.

Since this will involve restarting nginx with known-broken config,
you may be happier doing it on a non-production system.

So: one test can be about the number of files -- if "195 is good; 197
is bad" is true in general.

What I think you have reported is that with 195 files, things work; if
you add the new config to the end of a current file, things work; but if
you add the new config to new files instead of current files, things fail.

On a system that shows that behaviour, can you have the config in the
two new files so that it fails; and then delete five other files so
that you have less than 195 files again.

Does that work or fail? If it works, it suggests that there may be a
file-count limit; if it fails, it suggests that the problem is not with
the number of files.


Another test can be about the config. With the 195-files case where it
works, with the new config at the end of a current file, can you write
the output of "nginx -T" to a file -- for example:

nginx -T > 195-works

And then with the 197-files case where it fails, can you do something
similar:

nginx -T > 197-fails

Then you can play "spot-the-difference" between the two files, such as
by doing

diff -u 195-works 197-fails

What you should see there is probably exactly the same content with +
and - marks at the start, as the new config is probably in different
places in the full config. If there is anything other than that, it may
be interesting.

(Also: the diff output should be mostly just the new config, so should
be much smaller than the full config, and should have much less private
information, so may be easier to edit before sharing, if that is a useful
thing to do.)

Maybe one or other of those tests will show something that will help
identify the source of the problem.

If you can afford the effort to try that, it may help the next person
who has the same issue.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login