# Strange directory behaviour: rename causes 404 error

**URL:** <https://www.ruby-forum.com/t/strange-directory-behaviour-rename-causes-404-error/211406>\
**Category:** NGINX\
**Created:** [September 2, 2011, 10:33pm UTC](https://www.ruby-forum.com/t/strange-directory-behaviour-rename-causes-404-error/211406 "2011-09-02T22:33:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 2, 2011, 10:33pm UTC](https://www.ruby-forum.com/t/strange-directory-behaviour-rename-causes-404-error/211406/1 "2011-09-02T22:33:04Z")

</div>

Hi,

I have strange behaviour. I have a directory “@docencia”. All is ok:

172.26.0.6 - - [02/Sep/2011:22:26:10 +0200] “GET /@docencia/ HTTP/1.1”  
200 218 “[https://172.26.0.3/](https://172.26.0.3/)” “Mozilla/5.0 (X11; Linux i686; rv:6.0.1)  
Gecko/20100101 Firefox/6.0.1”

but when I rename to “docencia”, I have:

172.26.0.6 - - [02/Sep/2011:22:27:59 +0200] “GET /docencia/ HTTP/1.1”  
404 244 “[https://172.26.0.3/](https://172.26.0.3/)” “Mozilla/5.0 (X11; Linux i686; rv:6.0.1)  
Gecko/20100101 Firefox/6.0.1”

I don’t know why. Any hint.  
Please, help me.

Xan.

My nginx.conf is:  
user www-data;  
worker\_processes 1;

pid /var/run/nginx.pid;

events {  
worker\_connections 1024;  
# multi\_accept on;  
}

http {  
include /etc/nginx/mime.types;

```
# =logs:
access_log|_/var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;

# =compressió:
gzip on;
gzip_min_length 100;
gzip_types text/plain text/css text/xml application/x-javascript

```

application/atom+xml;

```
# =inclusió dels servidors virtuals
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

```

}

and /etc/nginx/sites-enabled/ only has default:

# You may add here your

# server {

# …

# }

# statements for each of your virtual hosts

# Servidor pla (http).

server {  
listen 80 default;  
server\_name localhost;

location / {  
rewrite ^(.\*)$ https://$host$1 permanent;  
}

# Per a què no me doni error si el navegador me demana favicon.ico i

no el

# tenc. De [[Matomo | NGINX](http://wiki.nginx.org/Piwik)]

# location = /favicon.ico {

```
    # try_files /favicon.ico =204;
    #}

```

# Seguint [http://wiki.nginx.org/ThttpdCGI](http://wiki.nginx.org/ThttpdCGI)

#location ~ .pl$ {

# #include proxy.conf;

# proxy\_intercept\_errors on;

# proxy\_pass [http://127.0.0.1:8082](http://127.0.0.1:8082);

# proxy\_redirect off;

# proxy\_set\_header X-Real-IP $remote\_addr;

# proxy\_set\_header Host $host;

# proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

# #proxy\_redirect default;

# #real\_ip\_header X-Real-IP;

# #proxy\_set\_header Connection Close;

```
    # #proxy_intercept_errors on;

```

#}

```
    #location ~ \.php$ {
    # #include proxy.conf;
    # proxy_intercept_errors on;
    # proxy_pass http://127.0.0.1:8082; #8082 --> lighttpd
    # proxy_redirect off;
    # proxy_set_header X-Real-IP $remote_addr;
    # proxy_set_header Host $host;
    # proxy_set_header X-Forwarded-For

```

$proxy\_add\_x\_forwarded\_for;

```
     # #proxy_redirect default;
     # #real_ip_header X-Real-IP;
     # #proxy_set_header Connection Close;
     # #proxy_intercept_errors on;
    #}

```

# Estat de les connexions del nginx.

# De [[Monitoring nginx Server Statistics With rrdtool :: Oleksiy Kovyrin](http://kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/)]

#location /status {

# stub\_status on;

# access\_log off;

# allow 127.0.0.1;

```
    # allow 172.26.0.0/24;

```

# deny all;

```
    #}

```

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

# 

#location ~ .php$ {  
#proxy\_pass[http://127.0.0.1](http://127.0.0.1);  
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

# 

#location ~ .php$ {  
#fastcgi\_pass 127.0.0.1:9000;  
#fastcgi\_index index.php;  
#fastcgi\_param SCRIPT\_FILENAME /scripts$fastcgi\_script\_name;  
#includefastcgi\_params;  
#}

# deny access to .htaccess files, if Apache’s document root

# concurs with nginx’s one

# 

#location ~ /.ht {  
#deny all;  
#}  
}

# Servidor SSL (https)

server {  
server\_name localhost;  
listen 443;

```
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;

location / {
root /var/www;
index index.html index.htm index.php;
autoindex on;
autoindex_exact_size off;
}

location /doc {
            root /usr/share;
            autoindex on;
autoindex_exact_size off;
            allow 127.0.0.1;
            allow 172.26.0.0/24;
            deny all;
}

```

# 400 = Bad request

```
    error_page 400 /400.html;
    location = /400.html {
            root /var/www/code-pages;
    }

    # 401 = Unauthorized
    error_page 401 /401.html;
    location = /401.html {
            root /var/www/code-pages;
    }

    # 403 = Forbidden page
    error_page 403 /403.html;
    location = /403.html {
            root /var/www/code-pages;
    }

    # 404 = Not found
    error_page 404 /404.html;
    location = /404.html {
            root /var/www/code-pages;
    }

    # 500 = Internal Server Error
    #
    error_page 500 /500.html;
    location = /500.html {
            root /var/www/code-pages;
    }

    # 501 = Not Implemented
    #
    error_page 501 /501.html;
    location = /501.html {
            root /var/www/code-pages;
    }

    # 502 = Bad Gateway
    #
    error_page 502 /502.html;
    location = /502.html {
            root /var/www/code-pages;
    }

    # 503 = Service Unavaliable
    #
    error_page 503 /503.html;
    location = /503.html {
            root /var/www/code-pages;
    }

    # 504 = Gateway Timeout
    #
    error_page 504 /504.html;
    location = /504.html {
            root /var/www/code-pages;
    }

    # 505 = HTTP Version Not Supported
    #
    error_page 505 /505.html;
    location = /505.html {
            root /var/www/code-pages;
    }

    # Per a què no me doni error si el navegador me demana

```

favicon.ico i no el  
# tenc. De [[Matomo | NGINX](http://wiki.nginx.org/Piwik)]  
location = /favicon.ico {  
try\_files /favicon.ico =204;  
}

# Execució de scripts de perl per proxy i lighttpd

# Informació original [http://wiki.nginx.org/ThttpdCGI](http://wiki.nginx.org/ThttpdCGI)

```
    location ~ \.pl$ {
            #include proxy.conf;
            proxy_intercept_errors on;
            proxy_pass http://127.0.0.1:8082;
#En teoria 8443; per ser segur entre servidors
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For

```

$proxy\_add\_x\_forwarded\_for;

```
            #proxy_redirect default;
            #real_ip_header X-Real-IP;
            #proxy_set_header Connection Close;
            #proxy_intercept_errors on;
    }

```

# # Per executar php via fastcgi (php-fpm).

# # NO descomentar.

# location ~ .php$ {

# include /etc/nginx/fastcgi\_params;

# #fastcgi\_pass unix:/var/run/php-fpm/php-fpm.sock;

# #fastcgi\_param SCRIPT\_FILENAME

$document\_root$fastcgi\_script\_name;

# fastcgi\_pass 127.0.0.1:9000;

# }

# Execució de php per proxy a lighttpd

```
    location ~ \.php$ {
            #include proxy.conf;
            #proxy_intercept_errors on;
            proxy_pass http://127.0.0.1:8082; #8082 --> lighttpd
##proxy_set_header X-Forwarded-Host $host;
    ##proxy_set_header X-Forwarded-Server $host;
    ##proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            #proxy_redirect off;
#proxy_buffering off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;

```

#$proxy\_add\_x\_forwarded\_for;  
#proxy\_set\_header X-Forwarded-Ssl on;

```
            ##proxy_redirect default;
            ##real_ip_header X-Real-IP;
            ##proxy_set_header Connection Close;
            ##proxy_intercept_errors on;
    }

```

location /segur/ {  
auth\_basic “Zona restringida”;  
auth\_basic\_user\_file conf.d/contrasenyes;  
root /var/www/;  
autoindex on;  
}

```
    # Estat de les connexions del nginx.
    # De

```

[[Monitoring nginx Server Statistics With rrdtool :: Oleksiy Kovyrin](http://kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/)]  
location /status {  
stub\_status on;  
access\_log off;  
allow 127.0.0.1;  
allow 172.26.0.0/24;  
deny all;  
}

}

# another virtual host using mix of IP-, name-, and port-based

configuration

# 

#Server {  
#listen 8000;  
#listen somename:8080;  
#server\_name somename alias another.alias;

#location / {  
#root html;  
#index index.html index.htm;  
#}  
#}

# HTTPS server

# 

#Server {  
#listen 443;  
#server\_name localhost;

#ssl on;  
#ssl\_certificate cert.pem;  
#ssl\_certificate\_key cert.key;

#ssl\_session\_timeout 5m;

#ssl\_protocols SSLv2 SSLv3 TLSv1;  
#ssl\_ciphers  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;  
#ssl\_prefer\_server\_ciphers on;

#location / {  
#root html;  
#index index.html index.htm;  
#}  
#}

Posted at Nginx Forum:

> **[Strange directory behaviour: rename causes 404 error](https://forum.nginx.org/read.php?2,214663,214663#msg-214663)**
>
> Hi, I have strange behaviour. I have a directory "@docencia". All is ok: 172.26.0.6 - - \[02/Sep/2011:22:26:10 +0200\] "GET /@docencia/ HTTP/1.1" 200 218 "https://172.26.0.3/" "Mozilla/5.0 (X11; Linux i686; rv:6.0.1)...

---

<div class="post-metadata">

**Author:** ![Xan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ac8455/32.png) [@Xan](https://www.ruby-forum.com/u/Xan)\
**Post date:** [September 2, 2011, 10:36pm UTC](https://www.ruby-forum.com/t/strange-directory-behaviour-rename-causes-404-error/211406/2 "2011-09-02T22:36:47Z")

</div>

Solved:

simply change: “location /doc” to “location /doc/”

That’s all. 🙂

Posted at Nginx Forum:

> **[Re: SOLVED Strange directory behaviour: rename causes 404 error](https://forum.nginx.org/read.php?2,214663,214664#msg-214664)**
>
> Hi, I have strange behaviour. I have a directory "@docencia". All is ok: 172.26.0.6 - - \[02/Sep/2011:22:26:10 +0200\] "GET /@docencia/ HTTP/1.1" 200 218 "https://172.26.0.3/" "Mozilla/5.0 (X11; Linux i686; rv:6.0.1)...

---

<div class="post-metadata">

**Author:** ![Xan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ac8455/32.png) [@Xan](https://www.ruby-forum.com/u/Xan)\
**Post date:** [September 3, 2011, 11:03am UTC](https://www.ruby-forum.com/t/strange-directory-behaviour-rename-causes-404-error/211406/3 "2011-09-03T11:03:11Z")

</div>

Xan, I suggest you take a look at this link -

> **[Setting up PHP-FastCGI and nginx? Don’t trust the tutorials: check...](https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/)**
>
> Summary Several days ago, I had to deal with a compromised web application: an attacker had somehow managed to upload PHP backdoor scripts onto the application’s server. Thanks to some log file sleuthing and Google searches, I was quickly able to...

Posted at Nginx Forum:

> **[Re: Strange directory behaviour: rename causes 404 error](https://forum.nginx.org/read.php?2,214663,214676#msg-214676)**
>
> Hi, I have strange behaviour. I have a directory "@docencia". All is ok: 172.26.0.6 - - \[02/Sep/2011:22:26:10 +0200\] "GET /@docencia/ HTTP/1.1" 200 218 "https://172.26.0.3/" "Mozilla/5.0 (X11; Linux i686; rv:6.0.1)...

---

<div class="post-metadata">

**Author:** ![Xan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ac8455/32.png) [@Xan](https://www.ruby-forum.com/u/Xan)\
**Post date:** [September 3, 2011, 4:10pm UTC](https://www.ruby-forum.com/t/strange-directory-behaviour-rename-causes-404-error/211406/4 "2011-09-03T16:10:57Z")

</div>

Report as bug  
[[Bug #840358 “By default configuration cause error 404 in directo...” : Bugs : nginx package : Ubuntu](https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/840358)] in  
ubuntu.

@ Samael: thanks.

Xan.

Posted at Nginx Forum:

> **[Re: SOLVED Strange directory behaviour: rename causes 404 error](https://forum.nginx.org/read.php?2,214663,214688#msg-214688)**
>
> Hi, I have strange behaviour. I have a directory "@docencia". All is ok: 172.26.0.6 - - \[02/Sep/2011:22:26:10 +0200\] "GET /@docencia/ HTTP/1.1" 200 218 "https://172.26.0.3/" "Mozilla/5.0 (X11; Linux i686; rv:6.0.1)...
