logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: Nginx config questions
Author
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Mon 16 Jun '14 22:07    Post subject: Nginx config questions Reply with quote

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

PostPosted: Tue 17 Jun '14 9:20    Post subject: Re: Nginx config questions Reply with quote

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

PostPosted: Tue 08 Jul '14 18:09    Post subject: Reply with quote

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. Question

Any idea what might be wrong?
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Tue 08 Jul '14 23:06    Post subject: Reply with quote

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

PostPosted: Tue 08 Jul '14 23:14    Post subject: Reply with quote

Nope, but once I disabled the firewall it worked..

Yes, but its supposed to load index.php trough apache and it doesn't Confused
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Wed 09 Jul '14 11:11    Post subject: Reply with quote

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

PostPosted: Wed 09 Jul '14 11:24    Post subject: Reply with quote

Code:
        location ~ \.php$ {
        proxy_pass   http://127.0.0.1:8000;
        }


I already had that enabled.. Neutral
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Wed 09 Jul '14 11:40    Post subject: Reply with quote

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


Reply to topic   Topic: Nginx config questions View previous topic :: View next topic
Post new topic   Forum Index -> Other Software