On my server, nginx proxies, and apache is behind it. There is such a problem that when I write a link in the form: https://example.com/orders/ , then everything is fine. And if at the end I don’t add a slash, the page simply doesn’t load and Conection Timed Out appears. And I just can not figure out whose fault it is - apache2 or nginx. What is the problem?

 server { listen 80; server_name jamesjgoodwin.ru www.jamesjgoodwin.ru; location ~ /.ht { deny all; } location / { if ($http_host ~ "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") { return 444; } rewrite ^(.*)$ https://jamesjgoodwin.ru$1 permanent; } location ~* \.(html|jpeg|jpg|gif|png|css|js|pdf|txt|tar|ico)$ { root /var/www/; expires 30d; } } server { listen 443 ssl; server_name jamesjgoodwin.ru www.jamesjgoodwin.ru; ssl on; ssl_certificate /etc/ssl/jamesjgoodwin.crt; ssl_certificate_key /etc/ssl/jamesjgoodwin.key; location / { proxy_pass http://127.0.0.1:81; index index.html index.php; proxy_redirect default; } } 

    2 answers 2

    This is neither a nginx bug, nor an httpd bug.

    You need to write <a href="/orders/hydrosystems/">link</a> , and the <a href="/orders/hydrosystems">link</a> option is WRONG in your case.

    See it.

    When you request a name with a slash at the end, it means that a folder is being requested (in the example, orders), which means that the index.html file that lies in this folder should be shown.

    When you request without a slash at the end, it means that the orders file (without the extension) is requested.

    In this config you don’t have any fault with either nginx or apache: what you submit in the browser is transferred (first to nginx, then to Apache).

    PS And it is not necessary to correct the curvature of incorrect links with crutches in nginx or httpd, although there are such methods ( DirectorySlash on in Apache's config).

    • I have a folder / orders / hydrosystems and the hydrosystems folder has index.html, but if I open the hydrosystems folder without a slash, then the site inside this folder will not open. And besides this folder there are others. So, setting rules for each individual folder is not an option. - JamesJGoodwin

    To solve this problem, I use .htaccess and similar rules.

     # Редирект для категорий (чтобы в конце URL был /) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !-f RewriteCond %{REQUEST_URI} !/$ RewriteCond %{REQUEST_URI} !.html$ RewriteCond %{REQUEST_URI} !.xml$ RewriteRule (.+) $1/ [R=301,L]