Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Setup multiple diffrents symfony-docker on the same domain. #740

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

Closed
NeyrowZ opened this issue Feb 16, 2025 · 1 comment
Closed

Setup multiple diffrents symfony-docker on the same domain. #740

NeyrowZ opened this issue Feb 16, 2025 · 1 comment

Comments

@NeyrowZ
Copy link

NeyrowZ commented Feb 16, 2025

I want to be able to have two (or more) of this project running at the same time on a single domain name (e.g. example.com and panel.example.com)
Since I don't fully understand the whole setup Caddy Mercure and stuff I came up with the idea of using an Nginx reverse proxy with a config to redirect let's say example.com on port 8000 and panel.example.com to another port for two sparated symfony-docker images.

I don't know if its best practice but i already run something on my VPS on an nginx container for redirection.

actualy the only way i found was to configurate only one port in the compose.yml like that:

ports:
  - target: 443
    published: 8000
    protocol: tcp

so localhost:8000 is working but I don't think its a good way to do it since in prod i'll force http https and http3 to use 443 port (actualy i don't realy know if its a problem but since there's 3 port config for 3 diffrent protocols maybe it matter)

Question:

Is there a way to setup multiple diffrents symfony-docker projects for a same domain name and should I try to configure Caddy or make my own reverse proxy.

@7-zete-7
Copy link
Contributor

Hi @NeyrowZ!

If I understood the question correctly, this issue can be solved by using Caddy-Docker-Proxy, Traefik, etc.

I can also suggest considering the possibility of running two projects under different domains on one machine.

For this, you can use the 127.0.0.1/8 subnet. When configuring port publishing with the host_ip attribute or the com.docker.network.bridge.host_binding_ipv4 option when creating a network, you can specify a specific IP address from the 127.0.0.1/8 subnet and place the service on it. In this case, the target ports should not be occupied on 127.0.0.1, since this will not allow publishing ports of the entire rest of the subnet.
Then, via /etc/hosts, you can configure the relationship between the configured domain and the IP address selected for the project.

Example

  • Create a new network
    docker network create -o com.docker.network.bridge.host_binding_ipv4=127.0.10.15 bridge_10_15
  • Configure the domain in /etc/hosts
    +127.0.10.15 project1.example.com
  • Configure the created network in compose.yaml
     services:
       php:
         networks:
    +      - hosted
         # ...
         environment:
    -      SERVER_NAME: ${SERVER_NAME:-localhost}
    +      SERVER_NAME: ${SERVER_NAME:-project1.example.com}
    
     # ...
    
     networks:
    +  hosted:
    +    external: true
    +    name: bridge_10_15

Repository owner locked and limited conversation to collaborators Feb 17, 2025
@maxhelias maxhelias converted this issue into discussion #741 Feb 17, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants