Good day. My nginx is configured as a proxy to apache. That is, nginx on port 80, and apache on 81. Here is the config:

server { listen 80; server_name jamesjgoodwin.ru www.jamesjgoodwin.ru; location / { rewrite ^(.*)$ https://jamesjgoodwin.ru$1 permanent; } } 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 off; } location ~* \.(html|jpeg|jpg|gif|png|css|js|pdf|txt|tar|ico)$ { root /var/www/; expires 30d; } location ~ /.ht { deny all; } if ($http_host ~ "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") { return 444; } } 

But for some reason, if I write a link without a slash at the end, then ERR_CONNECTION_REFUSED knocks me out. And in the address bar is added: 81 to my site, that is, redirect to port 81. If the link is closed with a slash, then this does not happen. How to fix this?

Closed due to the fact that off-topic participants aleksandr barakin , Denis , user194374, Bald , Regent July 29, '16 at 18:00 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - aleksandr barakin, Denis, Spirit of Community, Bald, Regent
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • proxy_redirect default; - nörbörnën
  • @norbornen did not help. - JamesJGoodwin
  • 2
    most likely a problem in the work of apache and / or scripts interpreted by it. check: wget -S --spider http://127.0.0.1:81/ссылка-без-слэша - aleksandr barakin
  • @alexanderbarakin yes, you were right. I changed the Listen 127.0.0.1:81 line in the apache config to just 81 and it all worked. - JamesJGoodwin
  • @alexanderbarakin Please post your comment as a response. - Nicolas Chabanovsky

1 answer 1

ERR_CONNECTION_REFUSED. And in the address bar is added: 81 to my site, that is, redirect to port 81.

The given fragment of the nginx configuration, in my opinion, cannot lead to a similar result.

The problem most likely lies in the configuration of the apache program that listens to port 81, or the operation of scripts interpreted by this instance of the program.

To verify this, compare the returned headers by running the commands on the server:

 $ wget -S --spider http://127.0.0.1:81/ссылка-без-слэша $ wget -S --spider http://127.0.0.1:81/ссылка-со-слэшем/