LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-29-2014, 09:07 AM   #1
Kraiser10
Member
 
Registered: Mar 2010
Posts: 52

Rep: Reputation: 15
How to secure nginx +php using fastcgi in shared enviorment


Hello I would like to know if I have many domains on one server how to secure the files so if someone will try to read/write to other domain he won't be able to.

For example user1 have domain1 in /var/www/domain1 and user2 have domain2 /var/www/domain2 now I dont want those 2 users to read/write files which are not theirs. How do I do that with nginx + php fastcgi?
 
Old 08-29-2014, 12:56 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
There's copious material out there on that. Each domain-definition should occupy its own set of "<location>s" and have its own set of directives ... and the PHP software which runs the site (which will probably run as "nobody") must be configured so that it will not attempt to read any outside locations, even though it can. The software must also be configured so that "rogue" URLs, including ".."s and such, are not honored. Spend 10 minutes surfing Google and you will have days' worth of material to ponder.
 
Old 08-31-2014, 03:49 AM   #3
Kraiser10
Member
 
Registered: Mar 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sundialsvcs View Post
There's copious material out there on that. Each domain-definition should occupy its own set of "<location>s" and have its own set of directives ... and the PHP software which runs the site (which will probably run as "nobody") must be configured so that it will not attempt to read any outside locations, even though it can. The software must also be configured so that "rogue" URLs, including ".."s and such, are not honored. Spend 10 minutes surfing Google and you will have days' worth of material to ponder.
Yeah well maybe im doing it wrong but I haven't found anything related to my question could you tell what you wrote in google search?

I have managed to make /var/www kinda chroot by using open_basedir but it still doesn't fixes my issue with permissions with diffrent domain if user1 manages to exploit web1 he will have READ access to web2 too .
structure of my server
/var/www/web1 phpcgi user/group
/var/www/web2 phpcgi2 user/group

when somebody will be able to exploit web1 he will have READ access to web2 too. I don't want to do that.

Last edited by Kraiser10; 08-31-2014 at 05:22 AM.
 
Old 08-31-2014, 06:41 AM   #4
Kraiser10
Member
 
Registered: Mar 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Ok here is what I did created 2 seperate php-cgi processes one under php-cgi port 9000 the other under php-cgi2 port 9001 user and passed to those in conf.d
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}

fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
include fastcgi_params;
}
other domain have same but 9000.

of nginx made chmod 640 on .php files and it seems like it works Im not sure if it is proper concept of making this right , Can this be exploited somehow ? I tried using c99 and there is no READ access to files except for .css not sure why I had to set 644 to css and image files to make my site work properly.
 
  


Reply

Tags
fastcgi, nginx, secure



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] fastcgi cannot find php files after I created nginx chroot environment Laertiades Linux - Server 1 01-30-2013 01:03 PM
[SOLVED] Nginx not passing the PHP scripts to FastCGI server listening on 127.0.0.1:9000 dreamcoder Linux - Server 8 08-02-2012 08:46 AM
LXer: How to Installing Nginx with PHP5-FastCGI and MySql Support on Ubuntu Server 12.04 LTS LXer Syndicated Linux News 0 06-15-2012 10:20 AM
LXer: PHP-FPM/Nginx Security In Shared Hosting Environments (Debian/Ubuntu) LXer Syndicated Linux News 0 09-25-2011 03:20 PM
LXer: Drupal 6 Hosting With nginx And PHP-FastCGI On Ubuntu 9.10 LXer Syndicated Linux News 0 04-08-2010 02:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration