-2

On a CentOS 6.6 box I have nginx set to serve two virtual hosts. One for SSL and one for basic HTTP.

/etc/nginx/default.conf:

server {
listen       80 default_server;
server_name  _;

#charset koi8-r;

#access_log  logs/host.access.log  main;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

error_page  404              /404.html;
location = /404.html {
    root   /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}
}

my /etc/nginx/conf.d/virtual.conf for HTTP:

server {
listen       example.com:80;
server_name  example.com  alias  www.example.com;

location / {
    root   /var/www/example.com/htdocs/;
    index  index.html index.htm index.php;
}

location ~ \.php$ {
    root           /var/www/example.com/htdocs/;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
}

My /etc/nginx/conf.d/ssl.conf:

server {
listen       443;
server_name  example.com;

ssl                  on;
ssl_certificate      /etc/nginx/ssl/nginx.crt;
ssl_certificate_key  /etc/nginx/ssl/nginx.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   /var/www/example.com/htocs/;
    index  index.html index.htm;
}

location ~ \.php$ {
    root           /var/www/example.com/htdocs/;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
 }
 }

contents of my htdocs folder:

[root@mydomain htdocs]# ls -lha
total 192K
drwxr-xr-x  5 myuser myuser 4.0K Mar  3 19:57 .
drwxr-xr-x  4 myuser myuser 4.0K Mar  3 18:52 ..
-rw-r--r--  1 root    root     418 Mar  3 19:54 index.php
-rw-r--r--  1 root    root      20 Mar  3 19:36 info.php
-rw-r--r--  1 root    root     20K Mar  3 19:54 license.txt
-rw-r--r--  1 root    root    7.1K Mar  3 19:54 readme.html
-rw-r--r--  1 root    root    4.9K Mar  3 19:54 wp-activate.php
drwxr-xr-x  9 root    root    4.0K Mar  3 19:54 wp-admin
-rw-r--r--  1 root    root     271 Mar  3 19:54 wp-blog-header.php
-rw-r--r--  1 root    root    4.9K Mar  3 19:54 wp-comments-post.php
-rw-r--r--  1 root    root    2.7K Mar  3 19:54 wp-config.php
-rw-r--r--  1 root    root    2.7K Mar  3 19:54 wp-config-sample.php
drwxr-xr-x  4 root    root    4.0K Mar  3 19:54 wp-content
-rw-r--r--  1 root    root    2.9K Mar  3 19:54 wp-cron.php
drwxr-xr-x 12 root    root    4.0K Mar  3 19:54 wp-includes
-rw-r--r--  1 root    root    2.4K Mar  3 19:54 wp-links-opml.php
-rw-r--r--  1 root    root    2.7K Mar  3 19:54 wp-load.php
-rw-r--r--  1 root    root     33K Mar  3 19:54 wp-login.php
-rw-r--r--  1 root    root    8.1K Mar  3 19:54 wp-mail.php
-rw-r--r--  1 root    root     11K Mar  3 19:54 wp-settings.php
-rw-r--r--  1 root    root     25K Mar  3 19:54 wp-signup.php
-rw-r--r--  1 root    root    4.0K Mar  3 19:54 wp-trackback.php
-rw-r--r--  1 root    root    3.0K Mar  3 19:54 xmlrpc.php

What I find puzzling is I can directly access https://example.com/info.php which serves the typical php config stuff. However trying to access anything else throws a 404.

Any advice?

3
  • 2
    you should really remove sslv2 and sslv3 as they have big security issues with them
    – Mike
    Mar 5, 2015 at 0:26
  • whats the error log say?
    – xeon
    Mar 5, 2015 at 3:38
  • Check the differences in your two server blocks (besides ssl related stuff) and you'll see the problem.
    – Alexey Ten
    Mar 5, 2015 at 6:38

1 Answer 1

2

Fix the typo root /var/www/example.com/htocs/;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .