I
I
Igor Bezlepkin2019-07-02 12:00:12
Nginx
Igor Bezlepkin, 2019-07-02 12:00:12

How to fix 504 Gateway Timeout?

Hey! Tell me from www. everything works, without www 504 Gateway Time-out
Primary nginx server, through proxy on apache

server {
        server_name site.ru www.site.ru;
        listen 193.124.90.225;
        listen 193.124.90.225:443 ssl;
        # disable_symlinks if_not_owner from=$root_path;
        set $root_path /var/www/user/data/www/site.ru;

        if ( $scheme = "http" ) {
            rewrite ^/(.*)$ https://$host/$1 permanent;
        }
        location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
            root $root_path;
            access_log /var/www/nginx-logs/user isp;
            access_log /var/www/httpd-logs/site.ru.access.log ;
            error_page 404 = @fallback;
        }
        location / {
            proxy_pass http://193.124.90.225:81;
            proxy_redirect http://193.124.90.225:81/ /;
            proxy_connect_timeout       600;
            proxy_send_timeout          600;
            proxy_read_timeout          600;
            send_timeout                600;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Real-IP $remote_addr;
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
latush, 2019-07-02
@latush

Either make a forced redirect to www, or deal with Apache.

V
Viktor Taran, 2019-07-02
@shambler81

server {
######################################################################
## Server configuration
######################################################################
        listen *:80;
        server_name antar-dv.ru www.antar-dv.ru   ;
        root /var/www/antar-dv.ru/web;
######################################################################
## Enable gzip for proxied requests and static files
######################################################################
    # Enable gzip for proxied requests and static files
    gzip on;
    gzip_proxied any;
    gzip_vary on;
    gzip_http_version 1.1;
    gzip_types application/javascript application/json text/css text/xml;
    gzip_comp_level 4;

######################################################################
## Log configuration
######################################################################
#Все логи отключены
        error_log /dev/null crit;
        access_log off;
######################################################################
## Errors send to apache2
######################################################################
# у апача своих алиасов куча,  а так же некоторая статика отдается
# средствамси php, по этому все ошибки обрабатывать только apache2
        error_page 401 403 404 405 500 502 503 = @fallback;
        location @fallback {
                proxy_pass              http://127.0.0.1:82;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                }

######################################################################
## Locations configuration
######################################################################
#Отключаем логирование ошибок No such file or directory
## Disable .htaccess files

        location ~ /\.ht {
                deny all;
                access_log off;
                log_not_found off;
        }
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
# сервисы  на сайте phpmyadmin почта и letxencrypt
        location /phpmyadmin/ {
                deny all;
                root  /usr/share/phpmyadmin/;
        }
        ##
        location /webmail/ {
                rewrite ^/(.*)$ https://$http_host:8080/$1 permanent;
        }
        # letsencrypt
         location /.well-known/acme-challenge/ {
                alias /usr/local/ispconfig/interface/acme/;
                default_type text/plain;

         }
# static content
# Отдаем статику напрямую с nginx
        location ~* ^.+\.(jpg|jpeg|svg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$ {
                root  /var/www/antar-dv.ru/web;
                access_log off;
                expires 30d;
                gzip_static on;
        }

# default location
        location / {
                index index.php index.html index.htm;
                proxy_pass              http://127.0.0.1:82;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                                }
}

server {

######################################################################
## Server configuration
######################################################################
        listen *:443 ssl http2;
                server_name antar-dv.ru www.antar-dv.ru   ;
        root /var/www/antar-dv.ru/web;

######################################################################
## Enable gzip for proxied requests and static files
######################################################################
    gzip on;
    gzip_proxied any;
    gzip_vary on;
    gzip_http_version 1.1;
    gzip_types application/javascript application/json text/css text/xml;
    gzip_comp_level 4;

######################################################################
## SSL configuration
######################################################################
        ssl on;
        ssl_session_cache  shared:SSL:10m;
        ssl_session_timeout 1h;
        ssl_protocols TLSv1.2 TLSv1.1;
        add_header Strict-Transport-Security "max-age=15768000" always;
        ssl_stapling on;
        ssl_stapling_verify on;
        ssl_prefer_server_ciphers on;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK;
        ssl_certificate /var/www/clients/client40/web42/ssl/antar-dv.ru-le.crt;
        ssl_certificate_key /var/www/clients/client40/web42/ssl/antar-dv.ru-le.key;
        ssl_dhparam /etc/nginx/ssl/dhparam.pem;
######################################################################
## Log configuration
######################################################################
#Все логи отключены
        error_log /dev/null crit;
        access_log off;


######################################################################
## Errors send to apache2
######################################################################
# у апача своих алиасов куча,  а так же некоторая статика отдается
# средствамси php, по этому все ошибки обрабатывать только apache2
        error_page 401 403 404 405 500 502 503 = @fallback;
        location @fallback {
                proxy_pass              https://127.0.0.1:4443;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header        HTTPS           YES;
                }

######################################################################
## Locations configuration
######################################################################
#Отключаем логирование ошибок No such file or directory
## Disable .htaccess files

        location ~ /\.ht {
                deny all;
                access_log off;
                log_not_found off;
        }
        ##
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
        ##
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
# сервисы  на сайте phpmyadmin почта и letxencrypt
        location /phpmyadmin/ {
                deny all;
                root  /usr/share/phpmyadmin/;
        }
        ##
        location /webmail/ {
                rewrite ^/(.*)$ https://$http_host:8080/$1 permanent;
        }
        # letsencrypt
         location /.well-known/acme-challenge/ {
                alias /usr/local/ispconfig/interface/acme/;
                default_type text/plain;

         }
# static content
# Отдаем статику напрямую с nginx
        location ~* ^.+\.(jpg|jpeg|svg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$ {
                root  /var/www/antar-dv.ru/web;
                access_log off;
                expires 30d;
                gzip_static on;
        }
# default location
        location / {
                index index.php index.html index.htm;
                proxy_pass              https://127.0.0.1:4443;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header        HTTPS           YES;
                        }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question