S
S
Stanislav2017-01-19 12:15:57
Nginx
Stanislav, 2017-01-19 12:15:57

Nginx send failed, why the error?

I screwed up somewhere, but I can't figure out where.
In general, I transferred sites to https and had to redo the configs.
In the logs I see the following

2017/01/19 11:52:52 [error] 27878#27878: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:52:52 [error] 27878#27878: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:52:53 [error] 27880#27880: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:52:57 [error] 27880#27880: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:53:03 [error] 27880#27880: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:53:35 [error] 27879#27879: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:53:49 [error] 27881#27881: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53
2017/01/19 11:53:54 [error] 27878#27878: send() failed (111: Connection refused) while resolving, resolver: ip_сервера:53

Configs:
Redirects /etc/nginx/sites-available/redirects
server {

    listen 80;
    listen [::]:80;

    server_name static.domain.ru;

    expires max;

    return 301 https://static.domain.ru$request_uri;

}

server {

    server_name domain.ru;

    listen domain.ru:443 ssl;

    ssl_certificate /etc/letsencrypt/live/domain.ru/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.ru/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/domain.ru/chain.pem;

    ssl_stapling on;
    ssl_stapling_verify on;
    resolver ip server 8.8.8.8;

    add_header Strict-Transport-Security "max-age=31536000";

    expires max;

    return 301 https://www.domain.ru$request_uri;

}

Config for domains with static
server {

    server_name img.domain.ru;

    listen img.domain.ru:443 ssl;

    ssl_certificate /etc/letsencrypt/live/domain.ru/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.ru/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/domain.ru/chain.pem;

    ssl_stapling on;
    ssl_stapling_verify on;
    resolver ip 8.8.8.8;

    add_header Strict-Transport-Security "max-age=31536000";

    add_header Content-Security-Policy "block-all-mixed-content";

    error_log /var/log/nginx/img.domain.ru.log crit;
    access_log off;

    # pass the request to the node.js server with the correct headers
    # and much more can be added, see nginx config options

    include acme;

    location / {

      root /var/www/img.domain.ru;
      expires 30d;

    }

}

Site config
upstream www.domain.ru {
    server 127.0.0.1:9000;
    keepalive 8;
}

# the nginx server instance
server {

    server_name www.domain.ru;

    listen www.domain.ru:443 ssl;

    ssl_certificate /etc/letsencrypt/live/domain.ru/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.ru/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/domain.ru/chain.pem;

    ssl_stapling on;
    ssl_stapling_verify on;
    resolver ip 8.8.8.8;

    add_header Strict-Transport-Security "max-age=31536000";

    add_header Content-Security-Policy "block-all-mixed-content";



    error_log /var/log/nginx/domain.ru.log crit;
    access_log off;

    # pass the request to the node.js server with the correct headers
    # and much more can be added, see nginx config options


    location / {

      root /var/www/domain.ru;

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://www.domain.ru/;
      proxy_redirect off;

    }

 }

And the main nginx.conf config
user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;


        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        #access_log /var/log/nginx/access.log;
        access_log off;
        error_log /var/log/nginx/error.log crit;


        ##
        # My Setting
        ##
        client_max_body_size 35M;
        client_body_buffer_size 4M;
        client_header_buffer_size 1M;
        large_client_header_buffers 8 640K;
        proxy_buffers 8 16k;
        proxy_buffer_size 16k;

        ssl_session_cache   shared:SSL:10m;
        ssl_session_timeout 10m;

        server_tokens off;

        open_file_cache max=200000 inactive=20s;
        open_file_cache_valid 60s;
        open_file_cache_min_uses 2;
        open_file_cache_errors on;

        charset UTF-8;

        reset_timedout_connection on;
        send_timeout 2;

        #client_max_body_size 16M;
        server_names_hash_bucket_size 128;


        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        gzip_min_length 10240;
        gzip_proxied expired no-cache no-store private auth;
        gzip_comp_level 5;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Burov, 2017-01-19
@BuriK666

(111: Connection refused) while resolving, resolver: server_ip:53
Can't connect to DNS. In resolverworking DNS servers.

P
Peter, 2017-01-19
@petermzg

It seems that the thing is that you write like this:
the documentation says that you need to specify the address here only if you want to bind the server to a different IP (if there are several), that is, here the server expects an IP address, not a domain name .
You just need to write:
listen 443 ssl;

S
Sergey Pankov, 2021-05-17
@trapwalker

Weird. There is no marked solution for more than three years.
You can just add your local domains to 127.0.0.1 in /etc/hosts
Then you don't need to go to nginx to go somewhere. to resolve local domains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question