Welcome! Log In Create A New Profile

Advanced

Re: noob needs help with alias locations and php

Francis Daly
May 28, 2015 04:04AM
On Wed, May 27, 2015 at 09:49:27PM -0700, Mike Wright wrote:

Hi there,

In general in nginx, one request is handled in one location. Only the
configuration in, or inherited into, that location, matters.

It you use rewrite-module directives, things are a bit more complicated.

There is lots at http://nginx.org/en/docs/; it may be hard to find the
one piece of information you want, but it is probably there somewhere.

> The server handles files and php scripts as long as they are at or
> beneath the document root. Here are the two problems I haven't been
> able to figure out:
> Directory index of ... is forbidden

What one request do you make that leads to that problem?

What is the one location that handles that request?

> Can't get to docs not beneath the document_root.

Same questions.

> Example of places I want to go:
>
> non-root targets: as:
> /home/mike/Movies/index.html /movies/index.html 200
> /home/mike/Movies/index.php /movies/index.php "File not found."
> /home/mike/Movies/1/index.html /movies/1/index.html 404
> /home/mike/Movies/1/index.php /movies/1/index.php "File not found."
>
> File not found : "Primary script unknown";
> 404 : the log shows the correct GET path;
> A lot of my experiments end up with 301 : endless redirects;
>
> http {
> index index.html index.php;
> ...
>
> server {
> listen 80;
> server_name localhost lo;
> root /var/www/sites/localhost/www;
>
> location / {
> try_files $uri $uri/ /index.html /index.php;
> }
>

The request "/movies/index.html" will be handled in this location:

> location /movies {
> alias /home/mike/Movies/;
> }

(Usually, it is good if the number of /s at the end of "alias" and and
the end of "location" are the same.)

The request "/movies/index.php" will be handled in this location:

> location ~ \.php$ {
> root /var/www/sites/localhost/www;
> include fastcgi_params;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> }
> }

Enable more logging; or "tcpdump", to see what nginx sends to your fastcgi
server. "/movies/index.php" is unlikely to be correctly handled here.

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

noob needs help with alias locations and php

Mike Wright May 28, 2015 12:50AM

Re: noob needs help with alias locations and php

Francis Daly May 28, 2015 04:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 319
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready