0
Не ошибка

Nginx custom configuration error

Thibaut 5 лет назад обновлен wrrr 6 месяцев назад 20
When adding directives in the "Custom top level configuration" section, a new server { } block is generated instead of adding the content inside the existing one. The result is two different server level blocks, giving Nginx conf errors.

On the other side, the regular non top level "Custom configuration" directives are correctly added inside the existing block.

Ответ

Ответ
Не ошибка
That's exactly what "Custom top level configuration" box is for. If you need configuration in the same server block, just use the other configuration field.
Ответ
Не ошибка
That's exactly what "Custom top level configuration" box is for. If you need configuration in the same server block, just use the other configuration field.
What should I do to make the following code work?

server {
    listen 80;
    server_name domain.com;
    return 301 https://domain.com$request_uri;
}
It gives an Nginx error, that's why I thought that there is a bug somewhere.

The code above gives this error: nginx: [warn] conflicting server name "example.comt" on 0.0.0.0:80, ignored
If I remove server { and } it becomes: nginx: [emerg] "listen" directive is not allowed here in /etc/nginx/conf.d/examplecom.conf:4
Here you are:

#AUTOMATICALLY GENERATED - DO NO EDIT!

server {
	listen 80;
	server_name domain.com;
	return 301 https://domain.com$request_uri;
}

server {
    listen *:80;
listen *:443 ssl spdy;
    ssl_certificate /etc/ssl/domain_com.crt;
    ssl_certificate_key /etc/ssl/domain_com.key;
    server_name domain.com;

    access_log /var/log/nginx/domaincom.access.log;
    error_log /var/log/nginx/domaincom.error.log;

    root /srv/domain.com;
    index index.html index.htm index.php;

    location = / {
	rewrite ^ http://anotherdomain.com permanent;
}

    
    
    location ~ [^/]\.php(/|$) {
        
        
        
        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/php-fcgi-domaincom-php-fcgi-0.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

}
This looks perfectly correct and works on my system. What does nginx -t say?
It returns this:

nginx: [warn] conflicting server name "domain.com" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Yes.
So, what can I do? Just ignore these warnings? I don't quite like that. ^^
Remove port 80 from the actual website, because you use the custom server entry to handle this port.
Would it be correct to never include port 80 in any website "Ports" screen and specify ports only when using https, for example?
Only when, like this time, you setup another nginx server to handle port 80
The weird thing about that is that I have another website with a similar server conf that doesn't generate the same issue. The port 80 is defined in the "Ports" tab and in the "Advanced" one.

server {
    listen 80;
    server_name www.example.com;
    return 301 http://example.com$request_uri;
}

server {
    listen *:80;
    server_name example.com;
(...)
that's because first one listens at www.example.com:80, and second one listens at example.com:80, therefore - no conflict
The warning for the previous website literally means that, if a "http://domain.com/" web request arrives, NGINX won't know whether it should go to the first server{}, or to the second one.

nginx: [warn] invalid value "TLSv1.3" in /etc/nginx/nginx.conf:50


This is in one install ? I have 2 other installs no insertion into nginx.conf

Ajenti  v1.2.23.13
+2

I fixed this in /var/lib/ajenti/plugins/vh-nginx/nginx_templates.py

How did it get changed is the question. I'm up for 1.3 but need more info.

Сервис поддержки клиентов работает на платформе UserEcho