V
V
ViktorGuerro2020-01-22 16:17:17
Nginx
ViktorGuerro, 2020-01-22 16:17:17

How to fix 400 Bad Request when going to folder without "/"?

There is a CentOS 7 web proxy implemented on nginx, when you go to a certain page, for example "domain.ru/test_directory", the error "400 Bad Request" occurs, and if you go to "domain.ru/test_directory/", then everything will work fine , config by domain:

server {
        listen 80;
        server_name domain.ru www.domain.ru;
        access_log /var/log/nginx/access/domain.ru/domain.ru.access.log;
        error_log /var/log/nginx/error/domain.ru/domain.ru.error.log;
        return 301 https://$server_name$request_uri; # редирект обычных запросов на https
}
server {
    listen 443 ssl http2;
    server_name domain.ru;
    access_log /var/log/nginx/access/domain.ru/domain.ru.access.log;
    error_log /var/log/nginx/error/domain.ru/domain.ru.error.log;
    ssl_certificate /etc/nginx/keys.ssl/domain.ru/domain_ru.crt;
    ssl_certificate_key /etc/nginx/keys.ssl/domain.ru/123456.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_dhparam /etc/nginx/keys.ssl/domain.ru/domain.ru.pem;
    ssl_ciphers 'EECDH+*****:EDH+AESGCM:AES256+*****:AES256+EDH';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

    location / {
        proxy_pass https://192.168.10.244;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question