Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Jul 02, 2011 2:52 pm 
Offline
Senior Member

Joined: Sun Sep 05, 2010 8:55 pm
Posts: 97
I was running a vBulletin site under a standard LAMP stack.

I spun up a new Linode to try LEMP instead, to see if it offered better performance.

I'm running into trouble trying to get the recommended "security enhancement" installed.

here's my php location block:

Code:
location ~ \.php$ {
                try_files $uri  =404;

                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /home/mouseowners-test/public_html$fastcgi_script_name;

        }


If I leave this as-is, every single PHP page I try and load (so, any of the vBulletin stuff) returns a 404. If I comment out the try_files line, everything seems to be working.

Any clues?


Top
   
 Post subject:
PostPosted: Sat Jul 02, 2011 3:31 pm 
Offline
Senior Newbie

Joined: Thu Jun 23, 2011 12:57 pm
Posts: 19
Can I see your entire vhost configuration?


Top
   
 Post subject:
PostPosted: Sat Jul 02, 2011 5:29 pm 
Offline
Senior Member

Joined: Sun Sep 05, 2010 8:55 pm
Posts: 97
Here's the entire file from sites-enabled:

Code:
# You may add here your
# server {
#       ...
# }
# statements for each of your virtual hosts

server {
        listen   80 default;
        server_name  mouseowners-test.com www.mouseoweners-test.com;

        access_log  /var/log/nginx/mouseowners-test.com.access.log;

        location / {
                root   /home/mouseowners-test/public_html;
                index  index.html index.htm index.php;
        }

        #error_page  404  /404.html;

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

        # proxy the PHP scripts to Apache listening on 127.0.0.1:81
        #
        #location ~ \.php$ {
                #proxy_pass   http://127.0.0.1:81;
                #proxy_set_header Host $http_host;
                #proxy_set_header X-Real-IP $remote_addr;
                #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                try_files $uri  =404;

                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /home/mouseowners-test/public_html$fastcgi_script_name;

        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
                #deny  all;
        #}
}


and here's nginx.conf:

Code:
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

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

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}



Thanks for looking!


Top
   
 Post subject:
PostPosted: Tue Jul 05, 2011 11:41 pm 
Offline
Senior Newbie

Joined: Thu Jun 23, 2011 12:57 pm
Posts: 19
Hey,

Sorry for the late response. Took some time off to recharge my batteriers.

Anyways. I don't see anything that stands out as an issue but I could make some guesses...

Have you tried using a home directory name without a dash in your path?

Code:
fastcgi_param SCRIPT_FILENAME /home/mouseowners-test/public_html$fastcgi_script_name;


This line right here may or may not be problematic with try files. All my paths don't have dashes in them...

Also I am curious as to what version of Nginx you are using so I can try to reproduce the problem. I am also curious... Did you disable the default vhost?

Also I believe nginx -t checks your configuration. Did you try running that?


Top
   
 Post subject:
PostPosted: Wed Jul 06, 2011 3:45 am 
Offline
Senior Member

Joined: Sat Nov 13, 2010 3:05 am
Posts: 91
Website: http://www.graq.co.uk
[snip] Some rubbish deleted! [/snip]

NB: Must engage brain


Last edited by graq on Wed Jul 06, 2011 7:56 am, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Wed Jul 06, 2011 7:25 am 
Offline
Senior Member

Joined: Sun Sep 05, 2010 8:55 pm
Posts: 97
I was using it to prevent this security hole:

https://nealpoole.com/blog/2011/04/sett ... iguration/

I'm still getting the error.

Sigh. Maybe I'll try varnish in front of apache.


Top
   
 Post subject:
PostPosted: Wed Jul 06, 2011 7:52 am 
Offline
Senior Member

Joined: Sat Nov 13, 2010 3:05 am
Posts: 91
Website: http://www.graq.co.uk
ericholtman wrote:
I was using it to prevent this security hole:

https://nealpoole.com/blog/2011/04/sett ... iguration/

I'm still getting the error.

Sigh. Maybe I'll try varnish in front of apache.
I'm being a dolt. I was trying to simplify the problem and making stupid assumptions. I should pay more attention.

I can only see 1 root declaration, namely inside your try_files[} block. Try either to move it out of there to give it a greater scope, or duplicate it inside your php block.


Top
   
 Post subject:
PostPosted: Wed Jul 06, 2011 8:15 am 
Offline
Senior Member

Joined: Sun Sep 05, 2010 8:55 pm
Posts: 97
mjruschak wrote:

Have you tried using a home directory name without a dash in your path?



Everything works if I just comment out the "try_files", so I don't think the path is the problem

Quote:
Also I am curious as to what version of Nginx you are using so I can try to reproduce the problem. I am also curious... Did you disable the default vhost?


0.7.65, and mouseowners-test.com is the only file in sites-enabled.

Quote:
Also I believe nginx -t checks your configuration. Did you try running that?


That comes up clean.


Top
   
 Post subject:
PostPosted: Wed Jul 06, 2011 12:38 pm 
Offline
Senior Member

Joined: Sun Feb 21, 2010 5:12 pm
Posts: 64
Try moving root out of location / and to the server scope under access_log.

I don't use vbulletin, but this might serve:
Code:
server {
  listen   80 default;
  server_name  mouseowners-test.com www.mouseoweners-test.com;

  access_log  /var/log/nginx/mouseowners-test.com.access.log;
  root   /home/mouseowners-test/public_html;
  index  index.html index.htm index.php;

  location / {
    try_files $uri $uri/ index.php;
  }

  # deny access to .htaccess files, .git, .svn, etc
  location ~ /\. {
    deny  all;
  }

  location ~ ^.+\.(jpg|jpeg|gif|png|ico|css|js)$ {
    access_log      off;
    expires         45d;
  }

  location ~ \.php$ {
    try_files $uri  =404;

    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/mouseowners-test/public_html$fastcgi_script_name;

  }
}


If you use fancier urls that don't include the php file then you'll need rewrites. vbseo.php probably requires something different, as well.


Top
   
 Post subject:
PostPosted: Wed Jul 06, 2011 1:04 pm 
Offline
Senior Member

Joined: Sun Sep 05, 2010 8:55 pm
Posts: 97
brianmercer wrote:
Try moving root out of location / and to the server scope under access_log.


Hey, that works, thanks!

Now I'll have to see if nginx + fast_cgi is better than varnish + apache.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
RSS

Powered by phpBB® Forum Software © phpBB Group