dunglas / symfony-docker

A Docker-based installer and runtime for Symfony. Install: download and `docker compose up`.
https://dunglas.dev/2021/12/symfonys-new-native-docker-support-symfony-world/
2.59k stars 771 forks source link

Access app with my local network ip #603

Closed rccc closed 6 months ago

rccc commented 7 months ago

Hello,

Il i try to connect with https:localhost, it works, but not with my own local ip !

My app have to run on local network.

How can i make it works with, for example 192.1.168.xxx.

Using the FrankenPHP image, i can set the SERVER_NAME option to 192.1.168.xxx and it works, but not for this image !

Many thanks in advance.

maxhelias commented 6 months ago

Hello,

It's a firewall or network issue, check your different configurations.

7-zete-7 commented 6 months ago

Hello, @rccc!

You don't need to use your machine's local address for FrankenPHP. FrankenPHP (it's Docker container) does not have this address at his disposal and cannot listen to ports on this address. Use SERVER_NAME=:80 to access the container from outside of your machine.

Reference to Caddy's addresses rules: https://caddyserver.com/docs/caddyfile/concepts#addresses

rccc commented 6 months ago

Hello @7-zete-7,

Many thanks for your kind response !

The link is a very interesting resources.

But if SERVER_NAME is "my_app", i do not think that https:://my_app:80 will be reachable from my local network unless i edit the hosts file on each computer in my local network... But i may wrong ...

Regards

7-zete-7 commented 6 months ago

@rccc, yes, without editing /etc/hosts file, the site will not open using https://my_app:80 link. Moreover, FrankenPHP will wait at port 80 only for HTTP, not HTTPS.

As a rule, they use the localhost host to simplify the deployment of a container for development.

If you need to use a specific host, you must add it to the /etc/hosts file manually by specifying the IP address 127.0.0.1 (or the external address of your host).

Examples

/etc/hosts

...
my_host 127.0.0.1
...

Starting a container

SERVER_NAME=my_app ...