Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP message: HTTP 404 (GET ) PHP message: [index.php:80] Base->run() #1025

Closed
hardware opened this issue Mar 10, 2018 · 12 comments
Closed

PHP message: HTTP 404 (GET ) PHP message: [index.php:80] Base->run() #1025

hardware opened this issue Mar 10, 2018 · 12 comments

Comments

@hardware
Copy link

hardware commented Mar 10, 2018

Hi everyone,

I tried to update selfoss to version 2.18 but nginx report an error from php-fpm :

2018/03/10 10:09:48 [error] 25#25: *1 FastCGI sent in stderr: "PHP message: HTTP 404 (GET ) PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 172.18.0.4, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "selfoss.domain.tld"

PHP message: HTTP 404 (GET ) PHP message: [index.php:80] Base->run()

I do not understand this error... it should work with my current setup.

Here my nginx configuration : https://github.com/hardware/selfoss/blob/master/rootfs/etc/nginx/nginx.conf

To reproduce this problem, you can build my docker image with selfoss 2.18 and look nginx logs with docker exec -ti selfoss tail -f /tmp/ngx_error.log

I use this docker image since selfoss 2.16 without any problem.

Any ideas ?

@tetradecahedron
Copy link

Can confirm this, i get the same message.
At first i built my own Alpine 3.7 from scratch with the official Selfoss 2.18 zip release, and today i tried to build @hardware image with 2.18.
I did try to run php-fpm in tcp listen (127.0.0.1:9000) mode as well and got the same message, but when i edited nginx.conf ´server_name´ to my host name i got it somewhat to work.
Using server_name _; in nginx.conf resulted in browser console error Loading failed for the <script> with source “http://_:80/all.js?v=1520262850”

@jtojnar
Copy link
Member

jtojnar commented Mar 10, 2018

Weird, the only thing I recall regarding routing was

It is now unlikely that the client browser gets outdated JS or CSS (#907) On Lighttpd, you might need to update your configuration.

but that should only affect all.{css,js} files and only lighttpd configuration from the wiki. Your nginx configuration looks fine as far as I can tell.

Sorry, I am not very familiar with docker. Do you have a list of commands I can run to build and spin up the container including changing the version?

@hardware
Copy link
Author

hardware commented Mar 10, 2018

Sure, change VERSION and SHA256_HASH arguments in the Dockerfile :

ARG VERSION=2.18
ARG SHA256_HASH="0b3d46b0b25170f99e3e29c9fc6a2e5235b0449fecbdad902583c919724aa6ed"

And in the same folder, build the docker image and then run it :

docker build -t selfoss .
docker run -d --name selfoss -p 80:8888 -v /mnt/docker/selfoss:/selfoss/data selfoss

# Check http://127.0.0.1:80

# use the following command to open a shell in the container : 
docker exec -ti selfoss sh

> tail -f /tmp/ngx_error.log

2018/03/10 11:58:45 [error] 25#25: *1 FastCGI sent in stderr: "PHP message: HTTP 404 (GET )
PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 172.17.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "127.0.0.1"

@jtojnar
Copy link
Member

jtojnar commented Mar 10, 2018

Maybe it is this bug. Not sure what could be causing it, though. For the record, selfoss 2.17 uses fatfree 3.6.0, selfoss 2.18 upgraded to 3.6.3.

@hardware
Copy link
Author

Or this : bcosca/fatfree#1060 The current nginx configuration causes fatfree (>= 3.6.2) routing to fail.

@jtojnar can you share your $_SERVER variables ?

$_SERVER['HTTP_X_REAL_IP'] | 172.18.0.1
$_SERVER['HTTP_X_FORWARDED_SERVER'] | bf376020b68b
$_SERVER['HTTP_X_FORWARDED_PROTO'] | https
$_SERVER['HTTP_X_FORWARDED_PORT'] | 443
$_SERVER['HTTP_X_FORWARDED_HOST'] | selfoss.domain.tld
$_SERVER['HTTP_X_FORWARDED_FOR'] | 172.18.0.1
$_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS'] | 1
$_SERVER['HTTP_CACHE_CONTROL'] | max-age=0
$_SERVER['HTTP_ACCEPT_LANGUAGE'] | en-US,en;q=0.9,fr;q=0.8
$_SERVER['HTTP_ACCEPT_ENCODING'] | gzip, deflate, br
$_SERVER['HTTP_ACCEPT'] | text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
$_SERVER['HTTP_USER_AGENT'] | Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
$_SERVER['HTTP_HOST'] | selfoss.domain.tld
$_SERVER['REDIRECT_STATUS'] | 200
$_SERVER['SERVER_NAME'] | no value
$_SERVER['SERVER_PORT'] | 8888
$_SERVER['SERVER_ADDR'] | 172.18.0.5
$_SERVER['REMOTE_PORT'] | 56802
$_SERVER['REMOTE_ADDR'] | 172.18.0.6
$_SERVER['SERVER_SOFTWARE'] | nginx/1.12.2
$_SERVER['GATEWAY_INTERFACE'] | CGI/1.1
$_SERVER['REQUEST_SCHEME'] | http
$_SERVER['SERVER_PROTOCOL'] | HTTP/1.1
$_SERVER['DOCUMENT_ROOT'] | /selfoss
$_SERVER['DOCUMENT_URI'] | /info.php
$_SERVER['REQUEST_URI'] | /info.php
$_SERVER['SCRIPT_NAME'] | /info.php
$_SERVER['CONTENT_LENGTH'] | no value
$_SERVER['CONTENT_TYPE'] | no value
$_SERVER['REQUEST_METHOD'] | GET
$_SERVER['QUERY_STRING'] | no value
$_SERVER['SCRIPT_FILENAME'] | /selfoss/info.php
$_SERVER['FCGI_ROLE'] | RESPONDER
$_SERVER['PHP_SELF'] | /info.php
$_SERVER['REQUEST_TIME_FLOAT'] | 1520687561.4374
$_SERVER['REQUEST_TIME'] | 1520687561

@jtojnar
Copy link
Member

jtojnar commented Mar 10, 2018

Adding var_dump($_SERVER); die; to the top of my index.php:

array(36) {
    ["USER"]=> string(6) "reader"
    ["HOME"]=> string(10) "/var/empty"
    ["HTTP_COOKIE"]=> string(56) "PHPSESSID=xxx; onlineSession=true"
    ["HTTP_UPGRADE_INSECURE_REQUESTS"]=> string(1) "1"
    ["HTTP_DNT"]=> string(1) "1"
    ["HTTP_ACCEPT_ENCODING"]=> string(17) "gzip, deflate, br"
    ["HTTP_ACCEPT_LANGUAGE"]=> string(14) "en-US,en;q=0.5"
    ["HTTP_ACCEPT"]=> string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
    ["HTTP_USER_AGENT"]=> string(68) "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
    ["HTTP_HOST"]=> string(15) "reader.xxx.xyz"
    ["PATH_TRANSLATED"]=> string(24) "/var/www/xxx.xyz/reader"
    ["PATH_INFO"]=> string(0) ""
    ["REDIRECT_STATUS"]=> string(3) "200"
    ["SERVER_NAME"]=> string(15) "reader.xxx.xyz"
    ["SERVER_PORT"]=> string(3) "443"
    ["SERVER_ADDR"]=> string(11) "xxx.xxx.xxx.xxx"
    ["REMOTE_PORT"]=> string(5) "37622"
    ["REMOTE_ADDR"]=> string(14) "xxx.xxx.xxx.xxx"
    ["SERVER_SOFTWARE"]=> string(12) "nginx/1.12.1"
    ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1"
    ["HTTPS"]=> string(2) "on"
    ["REQUEST_SCHEME"]=> string(5) "https"
    ["SERVER_PROTOCOL"]=> string(8) "HTTP/2.0"
    ["DOCUMENT_ROOT"]=> string(24) "/var/www/xxx.xyz/reader"
    ["DOCUMENT_URI"]=> string(10) "/index.php"
    ["REQUEST_URI"]=> string(1) "/"
    ["SCRIPT_NAME"]=> string(10) "/index.php"
    ["CONTENT_LENGTH"]=> string(0) ""
    ["CONTENT_TYPE"]=> string(0) ""
    ["REQUEST_METHOD"]=> string(3) "GET"
    ["QUERY_STRING"]=> string(0) ""
    ["SCRIPT_FILENAME"]=> string(34) "/var/www/xxx.xyz/reader/index.php"
    ["FCGI_ROLE"]=> string(9) "RESPONDER"
    ["PHP_SELF"]=> string(10) "/index.php"
    ["REQUEST_TIME_FLOAT"]=> float(xxxxx)
    ["REQUEST_TIME"]=> int(xxxxx)
}

@hardware
Copy link
Author

hardware commented Mar 10, 2018

location ~* \.php$ {
  try_files $uri =404;
  include /etc/nginx/fastcgi_params;
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param SERVER_NAME localhost;
}

Solution was to explicitly set the SERVER_NAME variable in my vhost conf. With docker, SERVER_NAME is of course equal to localhost.

fatfree developers should handle this automatically if SERVER_NAME isn't defined.

@jtojnar
Copy link
Member

jtojnar commented Mar 10, 2018

Will that work with domain names other than localhost?

@hardware
Copy link
Author

hardware commented Mar 10, 2018

Yes, for people who do not use docker, SERVER_NAME should be equal to the vhost domain name :

location ~* \.php$ {
  [...]
  fastcgi_param SERVER_NAME $host;
}

hardware/selfoss@1dd2172

@jtojnar
Copy link
Member

jtojnar commented Mar 10, 2018

Ok, can confirm this is fatfree regression. It works with 3.6.0:

FROM alpine:3.7

LABEL description "Multipurpose rss reader, live stream, mashup, aggregation web application" \
      maintainer="Hardware <[email protected]>"

ARG VERSION=2.18

ENV GID=991 UID=991 CRON_PERIOD=15m

RUN echo "@community http://nl.alpinelinux.org/alpine/v3.7/community" >> /etc/apk/repositories \
 && apk -U upgrade \
 && apk add -t build-dependencies \
    wget \
    git \
    nodejs \
    curl \
    openssl \
    php7-phar@community \
 && apk add \
    musl \
    nginx \
    s6 \
    su-exec \
    libwebp \
    ca-certificates \
    php7@community \
    php7-fpm@community \
    php7-gd@community \
    php7-json@community \
    php7-zlib@community \
    php7-xml@community \
    php7-dom@community \
    php7-curl@community \
    php7-iconv@community \
    php7-mcrypt@community \
    php7-pdo_mysql@community \
    php7-pdo_pgsql@community \
    php7-pdo_sqlite@community \
    php7-ctype@community \
    php7-session@community \
    php7-mbstring@community \
    tini@community \
 && git clone https://github.com/SSilence/selfoss.git /selfoss \
 && (cd /selfoss; git checkout 2.18) \
 && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
 && chmod +x /usr/local/bin/composer \
 && (cd /selfoss/public; npm install) \
 && (cd /selfoss; composer require bcosca/fatfree-core=3.6.0) \
 && (cd /selfoss; composer install) \
 && sed -i -e 's/base_url=/base_url=\//g' /selfoss/defaults.ini \
 && apk del build-dependencies \
 && rm /usr/local/bin/composer \
 && rm -rf /var/cache/apk/* /tmp/*

COPY rootfs /
RUN chmod +x /usr/local/bin/run.sh /services/*/run /services/.s6-svscan/*
VOLUME /selfoss/data
EXPOSE 8888
CMD ["run.sh"]

@jtojnar
Copy link
Member

jtojnar commented Mar 10, 2018

I have bisected it further and it was caused by f3-factory/fatfree-core@4d70bb4

~/selfoss-docker/Dockerfile
FROM alpine:3.7

LABEL description "Multipurpose rss reader, live stream, mashup, aggregation web application" \
      maintainer="Hardware <[email protected]>"

ARG VERSION=2.18

ENV GID=991 UID=991 CRON_PERIOD=15m

RUN echo "@community http://nl.alpinelinux.org/alpine/v3.7/community" >> /etc/apk/repositories \
 && apk -U upgrade \
 && apk add -t build-dependencies \
    wget \
    git \
    nodejs \
    curl \
    openssl \
    php7-phar@community \
 && apk add \
    musl \
    nginx \
    s6 \
    su-exec \
    libwebp \
    ca-certificates \
    php7@community \
    php7-fpm@community \
    php7-gd@community \
    php7-json@community \
    php7-zlib@community \
    php7-xml@community \
    php7-dom@community \
    php7-curl@community \
    php7-iconv@community \
    php7-mcrypt@community \
    php7-pdo_mysql@community \
    php7-pdo_pgsql@community \
    php7-pdo_sqlite@community \
    php7-ctype@community \
    php7-session@community \
    php7-mbstring@community \
    tini@community \
 && git clone https://github.com/SSilence/selfoss.git /selfoss \
 && (cd /selfoss; git checkout 2.18) \
 && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
 && chmod +x /usr/local/bin/composer \
 && composer config --global --auth github-oauth.github.com f27a8a7aa6c0e1deccb4e01022bfc9d84322e481 \
 && (cd /selfoss/public; npm install) \
 && (cd /selfoss; composer update)
RUN sed -i 's~"type": "project",~"type": "project", "repositories": [{"type": "vcs", "url": "https://github.com/bcosca/fatfree-core"}],~' /selfoss/composer.json \
 && sed -i 's~"^3.6"~"dev-master#2a2463f7f56baebe782958a652e757f6bbbb4264"~' /selfoss/composer.json \
 && (cd /selfoss; composer update) \
 && sed -i -e 's/base_url=/base_url=\//g' /selfoss/defaults.ini \
 && apk del build-dependencies \
 && rm /usr/local/bin/composer \
 && rm -rf /var/cache/apk/* /tmp/*

COPY rootfs /
RUN chmod +x /usr/local/bin/run.sh /services/*/run /services/.s6-svscan/*
VOLUME /selfoss/data
EXPOSE 8888
CMD ["run.sh"]
~/fatfree-core/bisect.sh
#!/usr/bin/env bash
commit=$(git rev-parse HEAD)
echo "****************" $commit
pushd ~/selfoss-docker
sed -i "s/dev-master#[a-f0-9]\+/dev-master#$commit/" Dockerfile
docker build -t selfoss .
docker run -d -p 900:8888 -v /mnt/docker/selfoss:/selfoss/data selfoss
popd
failed=0
sleep 60
curl http://localhost:900 | grep "error occured" && failed=1
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
exit $failed
$ git clone https://github.com/bcosca/fatfree-core.git
$ cd fatfree-core
$ git bisect start 3.6.2 3.6.1
Bisecting: 29 revisions left to test after this (roughly 5 steps)
[d2ebc80d31984bf84cf6ed2aed1d6fe05f7577aa] Assemble URL after ONREROUTE
$ bisect run ./bisect.sh
[...]
4d70bb4c6a1c30ecefc499a86dcaf54d3edc13fd is the first bad commit
commit 4d70bb4c6a1c30ecefc499a86dcaf54d3edc13fd
Author: xfra35 <[email protected]>
Date:   Wed Apr 5 23:26:43 2017 +0200

    Patched $_SERVER['REQUEST_URI'] to ensure it contains a relative URI.
    
    It could otherwise contain an absolute form (scheme+domain) in very
    specific cases. Cf. https://tools.ietf.org/html/rfc2616#section-5.1.2

:100644 100644 13f5ec2ac0486661ebf2e46c097e53c4554a4c57 72501b6f3a5de558b9260d62a9bd67bba3ab8202 M  base.php
bisect run success

@jtojnar
Copy link
Member

jtojnar commented Mar 3, 2019

This was fixed in fatfree 3.6.4 to which we switched in a1f7112.

@jtojnar jtojnar closed this as completed Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants