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

Running the webinterface on another port #20

Open
bbrala opened this issue Mar 12, 2018 · 25 comments
Open

Running the webinterface on another port #20

bbrala opened this issue Mar 12, 2018 · 25 comments
Assignees

Comments

@bbrala
Copy link

bbrala commented Mar 12, 2018

Hi,

I was trying to get this working on my dev env, but i can't reach the webinterface. Is there a possibility to run it on a different point so it doesn't conflict with apache?

Regards,

Bjorn.

@NoiseByNorthwest
Copy link
Owner

Hi,

The web UI does not include a dedicated HTTP server, it is simply served by the same server which served your PHP application.

Have you tried opening http://localhost/_spx?SPX_KEY=dev with the proper configuration as described here ?

@bbrala
Copy link
Author

bbrala commented Mar 12, 2018

Hmm, yeah i tried, i can only run it from my host machine (its an vm), and apache is just serving the vhost bound. When i run it with lynx from the console i get an 404.

@NoiseByNorthwest
Copy link
Owner

NoiseByNorthwest commented Mar 12, 2018

You should check your client ip var_dump($_SERVER['REMOTE_ADDR']); and put the right value in the configuration spx.http_ip_whitelist="<Your IPv4 address>"

@bbrala
Copy link
Author

bbrala commented Mar 12, 2018

I'll doublecheck that, since i did put my ip in the whitelist, but perhaps i made a typo. Ill get back to you.

@NoiseByNorthwest
Copy link
Owner

You may be interested by last revision of master which include some useful logs (in nginx error log or fpm error log) in case web ui access failure. See #23

@NoiseByNorthwest
Copy link
Owner

@bbrala as explained in this related issue #22 the UI root url without a trailing slash does not work. I've updated the README. You must use http://localhost/_spx/?SPX_KEY=dev instead.

@bbrala
Copy link
Author

bbrala commented Mar 14, 2018

Ah cool, tomorrow i have some time to check it out again. :)

@bbrala
Copy link
Author

bbrala commented Mar 15, 2018

Well, still not doing what it should really. I've build the current master.

Config file /etc/php/7.0/mods-available/spx.ini

[spx]
extension=spx.so
spx.http_enabled=1
spx.http_key=dev
spx.http_ip_whitelist=172.16.0.79,localhost

php -i | grep spx

spx.data_dir => /tmp/spx => /tmp/spx
spx.http_enabled => 1 => 1
spx.http_ip_var => REMOTE_ADDR => REMOTE_ADDR
spx.http_ip_whitelist => 172.16.0.79,localhost => 172.16.0.79,localhost
spx.http_key => dev => dev
spx.http_ui_assets_dir => /usr/share/misc/php-spx/assets/web-ui => /usr/share/misc/php-spx/assets/web-ui
spx.http_ui_uri_prefix => /_spx => /_spx

Apache log when trying to connect:

172.16.0.79 - - [15/Mar/2018:11:35:43 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.1" 404 497 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
172.16.0.79 - - [15/Mar/2018:11:35:43 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.1" 404 497 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
127.0.0.1 - - [15/Mar/2018:11:36:03 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 404 458 "-" "Lynx/2.8.9dev.8 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/3.4.9"
127.0.0.1 - - [15/Mar/2018:11:36:52 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 404 458 "-" "Lynx/2.8.9dev.8 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/3.4.9"

@bbrala
Copy link
Author

bbrala commented Mar 15, 2018

And th elocation of spx.ini. (apache has been restarted also)

$ locate spx.ini
/etc/php/7.0/apache2/conf.d/20-spx.ini
/etc/php/7.0/cli/conf.d/20-spx.ini

@bbrala
Copy link
Author

bbrala commented Mar 15, 2018

Hmm, could it be Apache is just not supported? :x

@NoiseByNorthwest
Copy link
Owner

Yes it is possible. I'll try with apache2 this evening.

@NoiseByNorthwest
Copy link
Owner

@bbrala I've an issue with apache2 / mod_php 7.0, web UI HTTP responses are ill-formed (see below). I'll fix it in a few days.

HTTP/1.1 200 OK
Date: Thu, 15 Mar 2018 21:51:52 GMT
Server: Apache/2.4.7 (Ubuntu)
Transfer-Encoding: chunked

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 12245

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>SPX Control Panel</title>
        <script>
        (() => {
...

@bbrala
Copy link
Author

bbrala commented Mar 16, 2018

Thanks :)

@cmizzi
Copy link

cmizzi commented Mar 16, 2018

I've got same result on apache2 / mod_php-5.6

@NoiseByNorthwest
Copy link
Owner

@bbrala @cmizzi You should try last master revision. It should be ok since merge of #34.

@bbrala
Copy link
Author

bbrala commented Mar 19, 2018

I tried again in master, unfortunately, it is still nog working. Commandline is fine, but through apache still gives an 404.

@cmizzi
Copy link

cmizzi commented Mar 19, 2018

Hum, it's look like to work for my configuration (apache2 / mod_php5.6 through nginx)

RUN set -xe \
    && cd /tmp \
    && git clone https://github.com/NoiseByNorthwest/php-spx.git \
    && cd php-spx \
    && phpize \
    && ./configure \
    && make \
    && make install \
    && echo "spx.http_enabled=1\nspx.http_key=\"dev\"\nspx.http_ip_whitelist=\"127.0.0.1,172.123.0.200\"\nspx.http_ui_assets_dir=/usr/share/misc/php-spx/assets/web-ui\nextension=spx.so" > /etc/php5/mods-available/spx.ini \
    && php5enmod spx

@cmizzi
Copy link

cmizzi commented Mar 19, 2018

But, for projects working on Laravel, I've got a 301 loop redirections

HTTP/1.1 301 Moved Permanently
Server: nginx/1.12.2
Date: Mon, 19 Mar 2018 09:41:03 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Location: /_spx/?SPX_KEY=dev
Vary: Accept-Encoding
HTTP/1.1 301 Moved Permanently
Server: nginx/1.12.2
Date: Mon, 19 Mar 2018 09:42:07 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: http://xxx/_spx?SPX_KEY=dev
Vary: Accept-Encoding

The first tries to append the ending / and the second removes it

Logs from mod_php

[19-Mar-2018 10:44:09 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:09 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:09 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:09 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:10 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:10 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:10 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:10 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:10 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0
[19-Mar-2018 10:44:10 Europe/Paris] PHP Notice:  SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0

Logs from Apache2

172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx?SPX_KEY=dev HTTP/1.0" 301 305 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"
172.123.0.200 - - [19/Mar/2018:10:44:55 +0100] "GET /_spx/?SPX_KEY=dev HTTP/1.0" 301 545 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36"

Edit: it seems the .htaccess is executed (and trailing slash is applied).

@NoiseByNorthwest
Copy link
Owner

@cmizzi OK I just see the .htaccess used by Laravel https://github.com/laravel/laravel/blob/master/public/.htaccess#L12

Is localhost/_spx/index.html?SPX_KEY=dev OK for you ? If so I will make /_spx redirecting to /_spx/index.html

@NoiseByNorthwest
Copy link
Owner

@bbrala Can you provide SPX notice logs ? (those starting with "SPX: access")
Can you also try (and give me the output with headers) the following urls ?
localhost/_spx?SPX_KEY=dev
localhost/_spx/?SPX_KEY=dev
localhost/_spx/index.html?SPX_KEY=dev

@cmizzi
Copy link

cmizzi commented Mar 20, 2018

@NoiseByNorthwest This seems to work. I would be great to redirect on it, I don't think I'm not the only one with this issue. I didn't try directly in apache configuration but it should work IMO

@NoiseByNorthwest
Copy link
Owner

@cmizzi done on master (redirection to .../index.html)

@bbrala
Copy link
Author

bbrala commented Mar 21, 2018

What do you mean with the SPX notice logs?

@NoiseByNorthwest
Copy link
Owner

NoiseByNorthwest commented Mar 21, 2018

This kind of log PHP Notice: SPX: access granted: "172.123.0.200" IP with "dev" key in Unknown on line 0 Please see @cmizzi comment above for a full example. BTW you need to set log_errors=1 in apache2's php.ini

I do not reproduce the apache2 bugs since merge of #34. So you have to help me by trying the urls listed in my previous comment and giving me back the response headers & spx notice logs.

Can you aslo give me your apache2 vhost setup & .htaccess ?

@melroy89
Copy link

melroy89 commented Feb 20, 2024

In my case it also doesn't work. I use:

spx.http_enabled=1
spx.http_key=dev
spx.http_ip_whitelist="*"
spx.http_trusted_proxies="*"

Everything is correctly installed. I use PHP fpm and Nginx. But the point is that I have a default fallback server configuration in Nginx, to catch all domains that aren't matching any of my server name configurations.

Hence the reason I think I just get my fallback URL, this localhost will never work in my Nginx setup:

curl http://localhost/?SPX_KEY=dev&SPX_UI_URI=/
[1] 3746249

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Such a server config may look like this:


server { 
        listen 80 reuseport default_server;
        # Enable http/3
        listen 443 quic reuseport default_server;
        listen 443 ssl reuseport default_server;

  
        server_name _;

        # Use the default nginx folder
        root /usr/share/nginx/html;
        index index.html index.htm;

        location / {
                try_files $uri $uri/ =404;
        }
}

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

4 participants