Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.infosystems.www.servers.unix > #532

OT: Nginx and php,pl,cgi in users subdirectory

From "J.O. Aho" <user@example.net>
Newsgroups comp.infosystems.www.servers.unix, comp.lang.php
Subject OT: Nginx and php,pl,cgi in users subdirectory
Date 2020-08-21 10:47 +0200
Message-ID <hq9g1sFlpgpU1@mid.individual.net> (permalink)
References <rhk6vi$oj3$40@gallifrey.nk.ca> <hq6o2tF47j0U1@mid.individual.net> <rhlrvb$2t0q$83@gallifrey.nk.ca> <hq7iefF9kf9U1@mid.individual.net> <rhmso2$bt6$49@gallifrey.nk.ca>

Cross-posted to 2 groups.

Show all headers | View raw


On 21/08/2020 00.16, The Doctor wrote:
> In article <hq7iefF9kf9U1@mid.individual.net>,
> J.O. Aho <user@example.net> wrote:
>> On 20/08/2020 14.57, The Doctor wrote:
>>> In article <hq6o2tF47j0U1@mid.individual.net>,
>>> Arno Welzel  <usenet@arnowelzel.de> wrote:
>>>> The Doctor:

We are quite off topic for c.l.p, so that why an OT in the subject.


>>>>> How does one configure  php, pl or cgi files is user subdirectories
>>>>> on nginx ?
>>>>
>>>> <https://www.google.com/search?q=nginx+php>
>>>>
>>>
>>> Tried that as well.
>>
>> There is no different of configuring userdir from configuring a normal
>> location. You will need to configure for each file extension.
>>
> 
> did that.  here is the error I am getting:
>  location ~ ^/~(.+?)(/.*)?$
> Logs:
> 
> 2020/08/16 20:05:09 [error] 1971#100506: *623 FastCGI sent in stderr: "Unable to
> +open primary script: /usr/home//html/~doctor/blog/serendipity/comment.php (No
> +such file or directory)" while reading response header from upstream, client:
> +46.229.168.152, server: www.nk.ca, request: "GET

Your regexp is incorrect, as Lew pointed out, but sadly his regexp will 
have same kind of issue and even if it had been working, there had been 
problem with potentially access directories that are not to ment to be 
served.

The regexp you are looking for is: ^/~([\w-]*)(/.*)?$

Next time you have issues with regexp in nginx, take a look at 
https://www.regextester.com/94055 and use the substitution section to 
see what values you really get.


>     alias /usr/home/$1/html/$2;
>    Why am I not getting  /usr/home/html/~doctor instead of /usr/home/doctor/html ?

I don't think you should have the tilde in the directory name, if you 
want to change the order, then you have to change the order in your 
alias, $1 is the username, the $2 is the path, so if you have 
/user/home/html directory filled with users web directories, tne you 
should have /usr/home/html/$1/$2. If you need to keep the tilde in the 
username, then you have to move the tilde in the regexp so it's inside 
the parentheses, but I recommend against that.


>      location ~ .*~.*\.php$ {
>         #root      html;
>   #try_files $uri  =404;
>      fastcgi_split_path_info ^(.+\.php)(/.+)$;
> 
>    # Mitigate https://httpoxy.org/ vulnerabilities
>    #fastcgi_param HTTP_PROXY "";
>         fastcgi_pass   unix:/var/run/php-fpm.sock;
>     fastcgi_index  index.php;
>         fastcgi_param  SCRIPT_FILENAME  /usr/home/$1/html$fastcgi_script_name;
>     include        /usr/local/etc/nginx/fastcgi_params;
>         }

This looks really messy and another potential error source.

     location ~ \.php$ {
         try_files $uri =404;
         include         fastcgi_params;
         fastcgi_pass    unix:/var/run/php-fpm.sock;
         fastcgi_index   index.php;
     }

that should be neater and less prone to fail.


PS. When you reply, remove the footer(s) if your news client don't 
manage to remove footers by itself.

-- 

  //Aho

Back to comp.infosystems.www.servers.unix | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-19 21:52 +0000
  Re: Nginx and php,pl,cgi in users subdirectory Jerry Stuckle <jstucklex@attglobal.net> - 2020-08-19 21:16 -0400
    Re: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-20 02:22 +0000
  Re: Nginx and php,pl,cgi in users subdirectory Arno Welzel <usenet@arnowelzel.de> - 2020-08-20 09:46 +0200
    Re: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-20 12:57 +0000
      Re: Nginx and php,pl,cgi in users subdirectory "J.O. Aho" <user@example.net> - 2020-08-20 17:16 +0200
        Re: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-20 22:16 +0000
          Re: Nginx and php,pl,cgi in users subdirectory Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-08-20 19:24 -0400
            Re: Nginx and php,pl,cgi in users subdirectory Eli the Bearded <*@eli.users.panix.com> - 2020-08-21 00:14 +0000
              Re: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-21 02:59 +0000
          OT: Nginx and php,pl,cgi in users subdirectory "J.O. Aho" <user@example.net> - 2020-08-21 10:47 +0200
            Re: OT: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-21 13:21 +0000
              Re: OT: Nginx and php,pl,cgi in users subdirectory "J.O. Aho" <user@example.net> - 2020-08-21 20:16 +0200
                Re: OT: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-21 22:57 +0000
                Re: OT: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-22 02:24 +0000
                Re: OT: Nginx and php,pl,cgi in users subdirectory Arno Welzel <usenet@arnowelzel.de> - 2020-08-23 13:50 +0200
                Re: OT: Nginx and php,pl,cgi in users subdirectory doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-08-23 12:38 +0000
                Re: OT: Nginx and php,pl,cgi in users subdirectory Arno Welzel <usenet@arnowelzel.de> - 2020-08-24 02:01 +0200

csiph-web