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

Option for the Mongoose web server to listen on all available ip addresses (local and public) #165

Closed
GoogleCodeExporter opened this issue Aug 28, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Mongoose allows to specify port-only to listen on and in such case the web server should be listening on all ip addresses available (127.0.0.1, 192.168.x.x, PUBLIC IP address). Example from mongoose docs: listening_ports 8080,8043s (the second port is for SLL and is optional). Currently phpdesktop forces a specific ip address be specified in settings.json. If the ip address is empty it assigns 127.0.0.1 by default. It should be allowed for the ip address to be "*" and in such case set the listening_ports option in mongoose to contain only port. Minor changes will be required in web_server.cpp:

Original issue reported on code.google.com by czarek.t...@gmail.com on 23 Apr 2015 at 10:06

@dimasskt
Copy link

dimasskt commented Dec 3, 2015

I'm thinking about work around this while this issue is not done.

Is there some known work around on it?

I am going to build a script that will set the ip of current machine to settings.json
and run php-desktop.

@cztomczak cztomczak changed the title Allow to listen on all ip addresses available Allow to listen on all available ip addresses Feb 23, 2016
@cztomczak cztomczak changed the title Allow to listen on all available ip addresses Option for the Mongoose web server to listen on all available ip addresses (local and public) Feb 23, 2016
cztomczak added a commit that referenced this issue Feb 23, 2016
…IP addresses available.

In settings.json set: "listen_on": ["*", 54007] - this will make web server to listen on 127.0.0.1
and on 192.168.0.x and also on a public internet ip address. During testing I only confirmed
that it listened on local ip addresses (127.xxx and 192.xxx), I couldn't make it work for the internet
ip address - not sure if this is an issue in Mongoose web server, or or my router's port forwarding
wasn't configured properly. Note also that when listen_on is set to "*" then the SERVER_NAME
environment variable will still be set to 127.0.0.1 - this may cause issues in PHP scripts that
depend on that env variable. To fix it add this code at the top of all your PHP scripts:
<?php $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"]; ?>
This will set SERVER_NAME to an ip address that the web server is being accessed from.
For example when accessing from 127.0.0.1 it will be set to that. When accessing from 192.168.0.2
then it will be 192.xxx in that case.
@cztomczak
Copy link
Owner

Done in commit 4b00009 . See it for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants