M
M
Mikhail Vorontsov2016-01-09 17:32:12
Nginx
Mikhail Vorontsov, 2016-01-09 17:32:12

nginx front + apache back. How to configure for different users?

Good time of the day. I'm trying to set up a bunch of apache + nginx to increase the speed of returning statics. However, it doesn't work. For security reasons, each site works under a separate user through suexec, respectively, in each directory, the rights to files belong to different users.

<VirtualHost 172.19.2.88:8080>
SuexecUserGroup "#500" "#500"
ServerName username.ru
DocumentRoot /home/gent/public_html
ErrorLog /var/log/virtualmin/username_error_log
</VirtualHost>

I think this piece is enough for understanding.
Next, I attach the corresponding nginx configs to each site:
user nginx;
server {
        listen       80;
        server_name  username.ru

        location / {
            proxy_pass          http://username.ru:8080/;
            proxy_redirect      off;
            proxy_set_header    Host $host;
            proxy_set_header    X-Real-IP $remote_addr;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 10m;
            proxy_connect_timeout 90;
        }
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|rar|tgz|gz|js|bzip2|zip|tar|tiff)$ {
            root /home/username/public_html;
        }
    }

However, the static is not given
[error] 37187#0: *3 open() "/home/username/public_html/style.css" failed (13: Permission denied)

If, of course, you change the user on behalf of which nginx is launched, then everything works, but only for a specific user. The rest of the sites are still down. nobody didn't help either.
Add. data:
permissions are set to 644 for all files in the public_html directory (this is relative to statics)
CentOS 7.2
nginx 1.6.3
Question: how to make nginx work and give statics? I feel that the answer is on the surface, but God forbid I work with nginx for the third time, and googling about nginx + suexec did not help ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2016-01-09
@mvorontcov

And on a directory costs 755 at least? If the start bit is not set on directories (all the way from root to static) - nginx will not be able to access there, even if the file has 644.
And, by the way, why is nginx so ancient? The mainline is 1.9.9 now, and 1.6.7 is missing a lot compared to 1.9 versions...

M
Mikhail Vorontsov, 2016-01-09
@mvorontcov

Thank you, Yuri. Something blurred his eyes, somehow he did not pay attention.
Regarding the version - what is in the repositories. Connected epel, remi and rpmforge (in addition to the standard ones).
UPD : connected the nginx repository, updated to version 1.8.0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question