question

Profamx-5134 avatar image
0 Votes"
Profamx-5134 asked shashishailaj edited

The web address like localhost and 127.0.0.1 only serve locally not serve over public Ip

Hi ,

Welcome Everyone

Here we take a example , in which we try to serve a simple program of any kind from local address to public ip..
But i faces some issue..

Ok Let start

os - ubuntu / any

Suppose we use php to serve a php file ...
Then , i assured you know this comman things to server by php.

php -S localhost:8080
php -S 127.0.0.1:8080

But But their is a problem

What? Do you want to listen

When you use (localhost/127.0.0.1) as address then php or any other app will start serving but the serve is limited to localhost ip it does not show over public ip...

But when we uses

php -S 0.0.0.0:8080
php -S 10.0.0.4:8080

Then it will serve not only localhost also visible through public it ..

Can you please fix it and what the reason

not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TakahitoIwasa avatar image
0 Votes"
TakahitoIwasa answered Profamx-5134 commented

Hi, @Profamx-5134

It's PHP's Built-in web server feature.

Please check the following URL.
https://www.php.net/manual/en/features.commandline.webserver.php

If 0.0.0.0 is specified, it can be accessed from any remote server. This is a PHP built-in web server specification, not an Azure issue.

The PHP documentation also notes the following:
You should not use it on public networks.

Warning
The built-in Web Server should not be used on a public network.

From here, I will talk about what you can do with Azure.

If you want to keep your Azure virtual network private, don't give it a public IP address.

https://docs.microsoft.com/en-us/azure/virtual-network/ip-services/public-ip-addresses

If you publish your PHP application on a public network, we recommend hosting it with Apache or Nginx and controlling the communication with a virtual network or firewall.
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-lamp-stack

You can also host your PHP application on Azure App Service.
https://docs.microsoft.com/en-us/azure/app-service/

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


You give me a Good reason for this i Appreciate it

But your reason in only valid over php...
In php , they say to use 0.0.0.0 for public and 127.0.0.1 for local
Ya i know that it true

But their is something

I said that when any program ( like php etc) run over localhost address then it is not visible over public ip..

So how we can visible this over public ip???
if i need ..

Lets take another example with python
May you know about ? You know

  1. Create simple app.py

  2. we user import flash and simple hello world , and create something

  3. Mean when i visited over this file on hosted address it return me " Hello world"

  4. Then we deploy this application with simple command

  5. flash run -p 8080

  6. It will run this program over locahost:8080

We test it works on not > curl localhost:8080
so it return > hello world and some errors ( debug enable )

so we try to access same program over our public ip

visited or curl over public ip and the port
It will not serve their ...

So what how i serve over their ,
Because in PhP you easily say about php function not a matter of azure
Ok
Then what is this !

Basically i know the answer and i also know how to serve over public ip
But i want to know from you???

Please reply it ??



0 Votes 0 ·
Profamx-5134 avatar image
0 Votes"
Profamx-5134 answered

You give me a Good reason for this i Appreciate it

But your reason in only valid over php...
In php , they say to use 0.0.0.0 for public and 127.0.0.1 for local
Ya i know that it true

But their is something

I said that when any program ( like php etc) run over localhost address then it is not visible over public ip..

So how we can visible this over public ip???
if i need ..

Lets take another example with python
May you know about ? You know

Create simple app.py

we user import flash and simple hello world , and create something

Mean when i visited over this file on hosted address it return me " Hello world"

Then we deploy this application with simple command

flash run -p 8080

It will run this program over locahost:8080

We test it works on not > curl localhost:8080
so it return > hello world and some errors ( debug enable )

so we try to access same program over our public ip

visited or curl over public ip and the port
It will not serve their ...

So what how i serve over their ,
Because in PhP you easily say about php function not a matter of azure
Ok
Then what is this !

Basically i know the answer and i also know how to serve over public ip
But i want to know from you???

Please reply it ??

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.