Author |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Mon 16 Jun '14 22:07 Post subject: Nginx config questions |
|
|
I keep getting location directive is not allowed in here errors from these piece's of code:
Code: | # For Naxsi remove the single # line for learn mode, or the ## lines for full WAF mode
location / {
#include /nginx/conf/mysite.rules; # see also http block naxsi include line
##SecRulesEnabled;
##DeniedUrl "/RequestDenied";
##CheckRule "$SQL >= 8" BLOCK;
##CheckRule "$RFI >= 8" BLOCK;
##CheckRule "$TRAVERSAL >= 4" BLOCK;
##CheckRule "$XSS >= 8" BLOCK;
root html;
index index.html index.htm;
} |
Code: | # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
#}
}
|
Code: | # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
proxy_pass http://127.0.0.1:8000;
#} |
Where should I put these?
I currently have them located just after all my settings for each domain. (similar to virtual hosts in Apache)
I tried moving them up into the http section but nginx didn't like that either. |
|
Back to top |
|
ng4win
Joined: 25 May 2014 Posts: 78
|
Posted: Tue 17 Jun '14 9:20 Post subject: Re: Nginx config questions |
|
|
First solve issues like:
Code: | # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
#}
}
|
You have marked the second } with a marker #
Code: | # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
proxy_pass http://127.0.0.1:8000;
#} |
You have marked the second } with a marker #
Balance your {}. |
|
Back to top |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Tue 08 Jul '14 18:09 Post subject: |
|
|
I no longer get any errors, but I still have problems.
I allowed the nginx.exe in the Windows Firewall but I don't see my external requests in the error.log
With local requests I get the following error:
403 Forbidden
nginx/1.7.2.1 RedKnight
And in the error.log:
2014/07/08 18:04:25 [error] 25192#43492: *1 directory index of "C:/Program Files/Apache Software Foundation/Apache24/htdocs/site 1/" is forbidden, client: 2001:1af8:4300:a037:2::, server: www.xgclan.com, request: "GET / HTTP/1.1", host: "www.xgclan.com"
It looks like my PHP processes are not send over to Apache.
I also can't access apache, I've set it to run at port 8000 and when I run my website with :8000 after the URL it doesn't load.
Any idea what might be wrong? |
|
Back to top |
|
ng4win
Joined: 25 May 2014 Posts: 78
|
Posted: Tue 08 Jul '14 23:06 Post subject: |
|
|
gijs wrote: | I no longer get any errors, but I still have problems.
I allowed the nginx.exe in the Windows Firewall but I don't see my external requests in the error.log
|
Can be a NAT issue, make sure your router is sending the proper external port to where nginx is listening.
Quote: |
2014/07/08 18:04:25 [error] 25192#43492: *1 directory index of "C:/Program Files/Apache Software Foundation/Apache24/htdocs/site 1/" is forbidden, client: 2001:1af8:4300:a037:2::, server: www.xgclan.com, request: "GET / HTTP/1.1", host: "www.xgclan.com"
|
It clearly says "directory index" so it wants to show you the contents which by default is not allowed, see http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
Without a full config to assess this remains guessing. |
|
Back to top |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Tue 08 Jul '14 23:14 Post subject: |
|
|
Nope, but once I disabled the firewall it worked..
Yes, but its supposed to load index.php trough apache and it doesn't  |
|
Back to top |
|
ng4win
Joined: 25 May 2014 Posts: 78
|
Posted: Wed 09 Jul '14 11:11 Post subject: |
|
|
If you want apache to handle php then use proxy_pass, otherwise nginx will deliver the context. |
|
Back to top |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Wed 09 Jul '14 11:24 Post subject: |
|
|
Code: | location ~ \.php$ {
proxy_pass http://127.0.0.1:8000;
} |
I already had that enabled..  |
|
Back to top |
|
ng4win
Joined: 25 May 2014 Posts: 78
|
Posted: Wed 09 Jul '14 11:40 Post subject: |
|
|
Then somehow another location block is preceding the php block since it is trying to serve context. With location its first match first serve. |
|
Back to top |
|