Discussion:
httpd - serving index.html & index.php at the same time
(too old to reply)
Mischa
2018-04-10 19:24:16 UTC
Permalink
Raw Message
Hi All,

Is there a way to serve both static and dynamic content, eg. index.html and index.php within the same server { } definition?
I am looking for something like:

server "default" {
listen on $ext_addr port 80
root "/htdocs"
directory index "index.html" # not needed as it's the default
location "/files/*" {
root "/htdocs/files"
directory auto index
}
location "^/phpapp/*" {
root "/htdocs/phpapp"
directory index "index.php"
fastcgi socket "/run/php-fpm.sock"
}
}

Is this possible at all or do I need split static and dynamic content based on server { }?

Thanx!!

Mischa
Gregory Edigarov
2018-04-11 08:00:25 UTC
Permalink
Raw Message
On 10.04.18 22:24, Mischa wrote:
> Hi All,
>
> Is there a way to serve both static and dynamic content, eg. index.html and index.php within the same server { } definition?
> I am looking for something like:
>
> server "default" {
> listen on $ext_addr port 80
> root "/htdocs"
> directory index "index.html" # not needed as it's the default
> location "/files/*" {
> root "/htdocs/files"
> directory auto index
> }
> location "^/phpapp/*" {
> root "/htdocs/phpapp"
> directory index "index.php"
> fastcgi socket "/run/php-fpm.sock"
> }
> }
>
> Is it possible at all or do I need split static and dynamic content based on server { }?
>
Seems like it should work exactly as you have written.
if not you should show more then you've shown.
Mischa
2018-04-11 08:40:04 UTC
Permalink
Raw Message
> On 11 Apr 2018, at 10:00, Gregory Edigarov <***@qarea.com> wrote:
>
> On 10.04.18 22:24, Mischa wrote:
>> Hi All,
>>
>> Is there a way to serve both static and dynamic content, eg. index.html and index.php within the same server { } definition?
>> I am looking for something like:
>>
>> server "default" {
>> listen on $ext_addr port 80
>> root "/htdocs"
>> directory index "index.html" # not needed as it's the default
>> location "/files/*" {
>> root "/htdocs/files"
>> directory auto index
>> }
>> location "^/phpapp/*" {
>> root "/htdocs/phpapp"
>> directory index "index.php"
>> fastcgi socket "/run/php-fpm.sock"
>> }
>> }
>>
>> Is it possible at all or do I need split static and dynamic content based on server { }?
>>
> Seems like it should work exactly as you have written.
> if not you should show more then you've shown.

Ok, good to know. It doesn't work as written. The only thing I see in the error.log is the fact that the PHP script is not found.

Access to the script '/htdocs/s/' has been denied (see security.limit_extensions)

Which tells me index.php is not requested.

Browser tells me: File not found

Running in debug mode it shows the following

default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/ HTTP/1.1" 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0"
default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408 0 "" ""
server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx, timeout (408 Request Timeout)
Primary script unknown
default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/ HTTP/1.1" 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0"

Not sure what else to look at. :((

Mischa
Gregory Edigarov
2018-04-11 10:14:00 UTC
Permalink
Raw Message
On 11.04.18 11:40, Mischa wrote
> Ok, good to know. It doesn't work as written. The only thing I see in the error.log is the fact that the PHP script is not found.
>
> Access to the script '/htdocs/s/' has been denied (see security.limit_extensions)
>
> Which tells me index.php is not requested.
>
> Browser tells me: File not found
>
> Running in debug mode it shows the following
>
> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/ HTTP/1.1" 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0"
> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408 0 "" ""
> server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx, timeout (408 Request Timeout)
> Primary script unknown
> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/ HTTP/1.1" 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0"
>
> Not sure what else to look at. :((
Did some tests.
here's how it works:

        location "/test" {
                block return 301 "/test/"
        }
        location "/test/" {
                root strip 1
                root "/htdocs/phpapp"
                directory index "test.php"
        }

note "root strip 1" directive.
Mischa
2018-04-11 14:32:11 UTC
Permalink
Raw Message
> On 11 Apr 2018, at 12:14, Gregory Edigarov <***@qarea.com> wrote:
>
> On 11.04.18 11:40, Mischa wrote
>> Ok, good to know. It doesn't work as written. The only thing I see in the error.log is the fact that the PHP script is not found.
>>
>> Access to the script '/htdocs/s/' has been denied (see security.limit_extensions)
>>
>> Which tells me index.php is not requested.
>>
>> Browser tells me: File not found
>>
>> Running in debug mode it shows the following
>>
>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/ HTTP/1.1" 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0"
>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408 0 "" ""
>> server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx, timeout (408 Request Timeout)
>> Primary script unknown
>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/ HTTP/1.1" 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0"
>>
>> Not sure what else to look at. :((
> Did some tests.
> here's how it works:
>
> location "/test" {
> block return 301 "/test/"
> }
> location "/test/" {
> root strip 1
> root "/htdocs/phpapp"
> directory index "test.php"
> }
>
> note "root strip 1" directive.

I had tried with strip 1 as well, it seems problem is with: fastcgi socket "/run/php-fpm.sock"
The working end result is something like:

server "default" {
listen on $ext_addr port 80
root "/htdocs/default"
location "^/phpapp/*" {
root { "/htdocs/phpapp", strip 1 }
directory index "index.php"
}
location match "^/phpapp/[%l%u%d]+$" {
root "/htdocs/phpapp/index.php"
fastcgi socket "/run/php-fpm.sock"
}
location "/*.php*" {
fastcgi socket "/run/php-fpm.sock"
}
}

Thank you very much for your response and testing. Really appreciate it.

Mischa
Bryan Harris
2018-04-11 20:40:24 UTC
Permalink
Raw Message
I'll ask a dumb question. Why do you need extra root directives? Can't you
do this?

location "^/phpapp/*" {
directory index "index.php"
}
location "*.php" {
fastcgi socket "/run/php-fmp.sock
}

Bryan

On Wed, Apr 11, 2018 at 10:32 AM, Mischa <***@high5.nl> wrote:

> > On 11 Apr 2018, at 12:14, Gregory Edigarov <***@qarea.com> wrote:
> >
> > On 11.04.18 11:40, Mischa wrote
> >> Ok, good to know. It doesn't work as written. The only thing I see in
> the error.log is the fact that the PHP script is not found.
> >>
> >> Access to the script '/htdocs/s/' has been denied (see
> security.limit_extensions)
> >>
> >> Which tells me index.php is not requested.
> >>
> >> Browser tells me: File not found
> >>
> >> Running in debug mode it shows the following
> >>
> >> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/ HTTP/1.1"
> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
> Gecko/20100101 Firefox/58.0"
> >> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408 0
> "" ""
> >> server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx,
> timeout (408 Request Timeout)
> >> Primary script unknown
> >> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/ HTTP/1.1"
> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
> Gecko/20100101 Firefox/58.0"
> >>
> >> Not sure what else to look at. :((
> > Did some tests.
> > here's how it works:
> >
> > location "/test" {
> > block return 301 "/test/"
> > }
> > location "/test/" {
> > root strip 1
> > root "/htdocs/phpapp"
> > directory index "test.php"
> > }
> >
> > note "root strip 1" directive.
>
> I had tried with strip 1 as well, it seems problem is with: fastcgi socket
> "/run/php-fpm.sock"
> The working end result is something like:
>
> server "default" {
> listen on $ext_addr port 80
> root "/htdocs/default"
> location "^/phpapp/*" {
> root { "/htdocs/phpapp", strip 1 }
> directory index "index.php"
> }
> location match "^/phpapp/[%l%u%d]+$" {
> root "/htdocs/phpapp/index.php"
> fastcgi socket "/run/php-fpm.sock"
> }
> location "/*.php*" {
> fastcgi socket "/run/php-fpm.sock"
> }
> }
>
> Thank you very much for your response and testing. Really appreciate it.
>
> Mischa
>
>


--
So the HP guy comes up to me and he says, 'If you say nasty things like
that to vendors you're not going to get anything'. I said 'no, in eight
years of saying nothing, we've got nothing, and I'm going to start saying
nasty things, in the hope that some of these vendors will start giving me
money so I'll shut up'.

-Theo De Raadt
Mischa
2018-04-11 20:47:29 UTC
Permalink
Raw Message
> On 11 Apr 2018, at 22:40, Bryan Harris <***@gmail.com> wrote:
>
> I'll ask a dumb question. Why do you need extra root directives? Can't you
> do this?
>
> location "^/phpapp/*" {
> directory index "index.php"
> }
> location "*.php" {
> fastcgi socket "/run/php-fmp.sock
> }
>
> Bryan
>

Not a dumb question and good suggestion. When location is in the same root as defined you can indeed.
When it's not you have to define an alternative root.

Also when you want to "rewrite" certain URLs to index.php for example, you have to define it as well.

Mischa

> On Wed, Apr 11, 2018 at 10:32 AM, Mischa <***@high5.nl> wrote:
>
>>> On 11 Apr 2018, at 12:14, Gregory Edigarov <***@qarea.com> wrote:
>>>
>>> On 11.04.18 11:40, Mischa wrote
>>>> Ok, good to know. It doesn't work as written. The only thing I see in
>> the error.log is the fact that the PHP script is not found.
>>>>
>>>> Access to the script '/htdocs/s/' has been denied (see
>> security.limit_extensions)
>>>>
>>>> Which tells me index.php is not requested.
>>>>
>>>> Browser tells me: File not found
>>>>
>>>> Running in debug mode it shows the following
>>>>
>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/ HTTP/1.1"
>> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
>> Gecko/20100101 Firefox/58.0"
>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408 0
>> "" ""
>>>> server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx,
>> timeout (408 Request Timeout)
>>>> Primary script unknown
>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/ HTTP/1.1"
>> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
>> Gecko/20100101 Firefox/58.0"
>>>>
>>>> Not sure what else to look at. :((
>>> Did some tests.
>>> here's how it works:
>>>
>>> location "/test" {
>>> block return 301 "/test/"
>>> }
>>> location "/test/" {
>>> root strip 1
>>> root "/htdocs/phpapp"
>>> directory index "test.php"
>>> }
>>>
>>> note "root strip 1" directive.
>>
>> I had tried with strip 1 as well, it seems problem is with: fastcgi socket
>> "/run/php-fpm.sock"
>> The working end result is something like:
>>
>> server "default" {
>> listen on $ext_addr port 80
>> root "/htdocs/default"
>> location "^/phpapp/*" {
>> root { "/htdocs/phpapp", strip 1 }
>> directory index "index.php"
>> }
>> location match "^/phpapp/[%l%u%d]+$" {
>> root "/htdocs/phpapp/index.php"
>> fastcgi socket "/run/php-fpm.sock"
>> }
>> location "/*.php*" {
>> fastcgi socket "/run/php-fpm.sock"
>> }
>> }
>>
>> Thank you very much for your response and testing. Really appreciate it.
>>
>> Mischa
>>
>>
>
>
> --
> So the HP guy comes up to me and he says, 'If you say nasty things like
> that to vendors you're not going to get anything'. I said 'no, in eight
> years of saying nothing, we've got nothing, and I'm going to start saying
> nasty things, in the hope that some of these vendors will start giving me
> money so I'll shut up'.
>
> -Theo De Raadt
Tom Smyth
2018-04-11 20:53:06 UTC
Permalink
Raw Message
Mischa
Hows it going ?
have you tried index.* for both html and php index support ?

I have been bailed out by the * before on php apps with seo friendly urls

On Wed 11 Apr 2018, 21:50 Mischa, <***@high5.nl> wrote:

>
> > On 11 Apr 2018, at 22:40, Bryan Harris <***@gmail.com> wrote:
> >
> > I'll ask a dumb question. Why do you need extra root directives? Can't
> you
> > do this?
> >
> > location "^/phpapp/*" {
> > directory index "index.php"
> > }
> > location "*.php" {
> > fastcgi socket "/run/php-fmp.sock
> > }
> >
> > Bryan
> >
>
> Not a dumb question and good suggestion. When location is in the same root
> as defined you can indeed.
> When it's not you have to define an alternative root.
>
> Also when you want to "rewrite" certain URLs to index.php for example, you
> have to define it as well.
>
> Mischa
>
> > On Wed, Apr 11, 2018 at 10:32 AM, Mischa <***@high5.nl> wrote:
> >
> >>> On 11 Apr 2018, at 12:14, Gregory Edigarov <***@qarea.com> wrote:
> >>>
> >>> On 11.04.18 11:40, Mischa wrote
> >>>> Ok, good to know. It doesn't work as written. The only thing I see in
> >> the error.log is the fact that the PHP script is not found.
> >>>>
> >>>> Access to the script '/htdocs/s/' has been denied (see
> >> security.limit_extensions)
> >>>>
> >>>> Which tells me index.php is not requested.
> >>>>
> >>>> Browser tells me: File not found
> >>>>
> >>>> Running in debug mode it shows the following
> >>>>
> >>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/
> HTTP/1.1"
> >> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
> >> Gecko/20100101 Firefox/58.0"
> >>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408
> 0
> >> "" ""
> >>>> server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx,
> >> timeout (408 Request Timeout)
> >>>> Primary script unknown
> >>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/
> HTTP/1.1"
> >> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
> >> Gecko/20100101 Firefox/58.0"
> >>>>
> >>>> Not sure what else to look at. :((
> >>> Did some tests.
> >>> here's how it works:
> >>>
> >>> location "/test" {
> >>> block return 301 "/test/"
> >>> }
> >>> location "/test/" {
> >>> root strip 1
> >>> root "/htdocs/phpapp"
> >>> directory index "test.php"
> >>> }
> >>>
> >>> note "root strip 1" directive.
> >>
> >> I had tried with strip 1 as well, it seems problem is with: fastcgi
> socket
> >> "/run/php-fpm.sock"
> >> The working end result is something like:
> >>
> >> server "default" {
> >> listen on $ext_addr port 80
> >> root "/htdocs/default"
> >> location "^/phpapp/*" {
> >> root { "/htdocs/phpapp", strip 1 }
> >> directory index "index.php"
> >> }
> >> location match "^/phpapp/[%l%u%d]+$" {
> >> root "/htdocs/phpapp/index.php"
> >> fastcgi socket "/run/php-fpm.sock"
> >> }
> >> location "/*.php*" {
> >> fastcgi socket "/run/php-fpm.sock"
> >> }
> >> }
> >>
> >> Thank you very much for your response and testing. Really appreciate it.
> >>
> >> Mischa
> >>
> >>
> >
> >
> > --
> > So the HP guy comes up to me and he says, 'If you say nasty things like
> > that to vendors you're not going to get anything'. I said 'no, in eight
> > years of saying nothing, we've got nothing, and I'm going to start saying
> > nasty things, in the hope that some of these vendors will start giving me
> > money so I'll shut up'.
> >
> > -Theo De Raadt
>
>
Mischa
2018-04-11 20:55:13 UTC
Permalink
Raw Message
> On 11 Apr 2018, at 22:53, Tom Smyth <***@wirelessconnect.eu> wrote:
>
> Mischa
> Hows it going ?
> have you tried index.* for both html and php index support ?
>
> I have been bailed out by the * before on php apps with seo friendly urls

Hey Tom!
Doing well man... looking forward to see you again at EuroBSD!

Not sure what you mean.


>
> On Wed 11 Apr 2018, 21:50 Mischa, <***@high5.nl> wrote:
>
>>
>>> On 11 Apr 2018, at 22:40, Bryan Harris <***@gmail.com> wrote:
>>>
>>> I'll ask a dumb question. Why do you need extra root directives? Can't
>> you
>>> do this?
>>>
>>> location "^/phpapp/*" {
>>> directory index "index.php"
>>> }
>>> location "*.php" {
>>> fastcgi socket "/run/php-fmp.sock
>>> }
>>>
>>> Bryan
>>>
>>
>> Not a dumb question and good suggestion. When location is in the same root
>> as defined you can indeed.
>> When it's not you have to define an alternative root.
>>
>> Also when you want to "rewrite" certain URLs to index.php for example, you
>> have to define it as well.
>>
>> Mischa
>>
>>> On Wed, Apr 11, 2018 at 10:32 AM, Mischa <***@high5.nl> wrote:
>>>
>>>>> On 11 Apr 2018, at 12:14, Gregory Edigarov <***@qarea.com> wrote:
>>>>>
>>>>> On 11.04.18 11:40, Mischa wrote
>>>>>> Ok, good to know. It doesn't work as written. The only thing I see in
>>>> the error.log is the fact that the PHP script is not found.
>>>>>>
>>>>>> Access to the script '/htdocs/s/' has been denied (see
>>>> security.limit_extensions)
>>>>>>
>>>>>> Which tells me index.php is not requested.
>>>>>>
>>>>>> Browser tells me: File not found
>>>>>>
>>>>>> Running in debug mode it shows the following
>>>>>>
>>>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/
>> HTTP/1.1"
>>>> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
>>>> Gecko/20100101 Firefox/58.0"
>>>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> " 408
>> 0
>>>> "" ""
>>>>>> server default, client 1 (1 active), 46.xx.xx.xx:4824 -> xx.xx.xx.xx,
>>>> timeout (408 Request Timeout)
>>>>>> Primary script unknown
>>>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/
>> HTTP/1.1"
>>>> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
>>>> Gecko/20100101 Firefox/58.0"
>>>>>>
>>>>>> Not sure what else to look at. :((
>>>>> Did some tests.
>>>>> here's how it works:
>>>>>
>>>>> location "/test" {
>>>>> block return 301 "/test/"
>>>>> }
>>>>> location "/test/" {
>>>>> root strip 1
>>>>> root "/htdocs/phpapp"
>>>>> directory index "test.php"
>>>>> }
>>>>>
>>>>> note "root strip 1" directive.
>>>>
>>>> I had tried with strip 1 as well, it seems problem is with: fastcgi
>> socket
>>>> "/run/php-fpm.sock"
>>>> The working end result is something like:
>>>>
>>>> server "default" {
>>>> listen on $ext_addr port 80
>>>> root "/htdocs/default"
>>>> location "^/phpapp/*" {
>>>> root { "/htdocs/phpapp", strip 1 }
>>>> directory index "index.php"
>>>> }
>>>> location match "^/phpapp/[%l%u%d]+$" {
>>>> root "/htdocs/phpapp/index.php"
>>>> fastcgi socket "/run/php-fpm.sock"
>>>> }
>>>> location "/*.php*" {
>>>> fastcgi socket "/run/php-fpm.sock"
>>>> }
>>>> }
>>>>
>>>> Thank you very much for your response and testing. Really appreciate it.
>>>>
>>>> Mischa
>>>>
>>>>
>>>
>>>
>>> --
>>> So the HP guy comes up to me and he says, 'If you say nasty things like
>>> that to vendors you're not going to get anything'. I said 'no, in eight
>>> years of saying nothing, we've got nothing, and I'm going to start saying
>>> nasty things, in the hope that some of these vendors will start giving me
>>> money so I'll shut up'.
>>>
>>> -Theo De Raadt
>>
>>
Tom Smyth
2018-04-11 21:10:45 UTC
Permalink
Raw Message
Hi Mischa
directory index "index.*"

To allow serving of index.php if its in the directory or index.html if that
is in the directory....
When both are present in a directory im not sure what would happen though

On Wed 11 Apr 2018, 21:55 Mischa, <***@high5.nl> wrote:

>
> > On 11 Apr 2018, at 22:53, Tom Smyth <***@wirelessconnect.eu>
> wrote:
> >
> > Mischa
> > Hows it going ?
> > have you tried index.* for both html and php index support ?
> >
> > I have been bailed out by the * before on php apps with seo friendly urls
>
> Hey Tom!
> Doing well man... looking forward to see you again at EuroBSD!
>
> Not sure what you mean.
>
>
> >
> > On Wed 11 Apr 2018, 21:50 Mischa, <***@high5.nl> wrote:
> >
> >>
> >>> On 11 Apr 2018, at 22:40, Bryan Harris <***@gmail.com> wrote:
> >>>
> >>> I'll ask a dumb question. Why do you need extra root directives? Can't
> >> you
> >>> do this?
> >>>
> >>> location "^/phpapp/*" {
> >>> directory index "index.php"
> >>> }
> >>> location "*.php" {
> >>> fastcgi socket "/run/php-fmp.sock
> >>> }
> >>>
> >>> Bryan
> >>>
> >>
> >> Not a dumb question and good suggestion. When location is in the same
> root
> >> as defined you can indeed.
> >> When it's not you have to define an alternative root.
> >>
> >> Also when you want to "rewrite" certain URLs to index.php for example,
> you
> >> have to define it as well.
> >>
> >> Mischa
> >>
> >>> On Wed, Apr 11, 2018 at 10:32 AM, Mischa <***@high5.nl> wrote:
> >>>
> >>>>> On 11 Apr 2018, at 12:14, Gregory Edigarov <***@qarea.com>
> wrote:
> >>>>>
> >>>>> On 11.04.18 11:40, Mischa wrote
> >>>>>> Ok, good to know. It doesn't work as written. The only thing I see
> in
> >>>> the error.log is the fact that the PHP script is not found.
> >>>>>>
> >>>>>> Access to the script '/htdocs/s/' has been denied (see
> >>>> security.limit_extensions)
> >>>>>>
> >>>>>> Which tells me index.php is not requested.
> >>>>>>
> >>>>>> Browser tells me: File not found
> >>>>>>
> >>>>>> Running in debug mode it shows the following
> >>>>>>
> >>>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:26 +0200] "GET /s/
> >> HTTP/1.1"
> >>>> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
> >>>> Gecko/20100101 Firefox/58.0"
> >>>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "<UNKNOWN> "
> 408
> >> 0
> >>>> "" ""
> >>>>>> server default, client 1 (1 active), 46.xx.xx.xx:4824 ->
> xx.xx.xx.xx,
> >>>> timeout (408 Request Timeout)
> >>>>>> Primary script unknown
> >>>>>> default 46.xx.xx.xx - - [11/Apr/2018:10:24:27 +0200] "GET /s/
> >> HTTP/1.1"
> >>>> 404 0 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0)
> >>>> Gecko/20100101 Firefox/58.0"
> >>>>>>
> >>>>>> Not sure what else to look at. :((
> >>>>> Did some tests.
> >>>>> here's how it works:
> >>>>>
> >>>>> location "/test" {
> >>>>> block return 301 "/test/"
> >>>>> }
> >>>>> location "/test/" {
> >>>>> root strip 1
> >>>>> root "/htdocs/phpapp"
> >>>>> directory index "test.php"
> >>>>> }
> >>>>>
> >>>>> note "root strip 1" directive.
> >>>>
> >>>> I had tried with strip 1 as well, it seems problem is with: fastcgi
> >> socket
> >>>> "/run/php-fpm.sock"
> >>>> The working end result is something like:
> >>>>
> >>>> server "default" {
> >>>> listen on $ext_addr port 80
> >>>> root "/htdocs/default"
> >>>> location "^/phpapp/*" {
> >>>> root { "/htdocs/phpapp", strip 1 }
> >>>> directory index "index.php"
> >>>> }
> >>>> location match "^/phpapp/[%l%u%d]+$" {
> >>>> root "/htdocs/phpapp/index.php"
> >>>> fastcgi socket "/run/php-fpm.sock"
> >>>> }
> >>>> location "/*.php*" {
> >>>> fastcgi socket "/run/php-fpm.sock"
> >>>> }
> >>>> }
> >>>>
> >>>> Thank you very much for your response and testing. Really appreciate
> it.
> >>>>
> >>>> Mischa
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> So the HP guy comes up to me and he says, 'If you say nasty things like
> >>> that to vendors you're not going to get anything'. I said 'no, in eight
> >>> years of saying nothing, we've got nothing, and I'm going to start
> saying
> >>> nasty things, in the hope that some of these vendors will start giving
> me
> >>> money so I'll shut up'.
> >>>
> >>> -Theo De Raadt
> >>
> >>
>
>
Kenneth Gober
2018-04-12 20:48:54 UTC
Permalink
Raw Message
On Tue, Apr 10, 2018 at 3:24 PM, Mischa <***@high5.nl> wrote:
> Is there a way to serve both static and dynamic content, eg. index.html and index.php within the same server { } definition?
> I am looking for something like:
>
> server "default" {
> listen on $ext_addr port 80
> root "/htdocs"
> directory index "index.html" # not needed as it's the default
> location "/files/*" {
> root "/htdocs/files"
> directory auto index
> }
> location "^/phpapp/*" {
> root "/htdocs/phpapp"
> directory index "index.php"
> fastcgi socket "/run/php-fpm.sock"
> }
> }

This is what I have and it works fine:

server aaaa.bbbb.net {
listen on * port 80
listen on * tls port 443
tls {
key "/path/to/my/key"
certificate "/path/to/my/cert"
}
root "/ftp"
directory auto index
location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}
}

Using this I can serve index.php and index.html from the same
directory (no need to segregate php into its own subdirectory).

-ken
Loading...