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

Why IP from website is gateway that not what I assigned the IP? #3001

Closed
sarukomine opened this issue Jun 24, 2021 · 0 comments
Closed

Why IP from website is gateway that not what I assigned the IP? #3001

sarukomine opened this issue Jun 24, 2021 · 0 comments

Comments

@sarukomine
Copy link

I want to assign static IP to the website, I googled many tutorial then follow them to update docker-compose yaml file as below.

WEBSERVER_SUBNET=192.168.0.0/16
WEBSERVER_IP_RANGE=192.168.10.0/24
WEBSERVER_GATEWAY=192.168.10.254
WEBSERVER_IP=192.168.10.10
version: '3.5'

networks:
  webserver:
    driver: ${NETWORKS_DRIVER}
    ipam:
      config:
        - subnet: ${WEBSERVER_SUBNET}
          gateway: ${WEBSERVER_GATEWAY}
          ip_range: ${WEBSERVER_IP_RANGE}
services:
  php-fpm:
    extra_hosts:
      - "dockerhost:${DOCKER_HOST_IP}"
      - "website-one.test:${WEBSERVER_IP}"
      - "wevsite-two.test:${WEBSERVER_IP}"
    networks:
      - webserver
      # - frontend
      # - backend
  nginx:
    extra_hosts:
      - "website-one.test:${WEBSERVER_IP}"
      - "wevsite-two.test:${WEBSERVER_IP}"
    networks:
      webserver:
        ipv4_address: ${WEBSERVER_IP}
      frontend:
      backend:

Then I can see nginx container are using 192.168.10.10 this IP and this is correct.

[
    {
        "Name": "xxx_webserver",
        "Id": "29546d3a16b20afaf3fa0c8a425affcdf84723665cfbbb431616c5b538b1cdeb",
        "Created": "2021-06-24T01:53:51.641484508Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "192.168.0.0/16",
                    "IPRange": "192.168.10.0/24",
                    "Gateway": "192.168.10.254"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "b7e6a5f9bdb5350049230f962f37ccf25f4b27cf7b67711764e97b3ea51db7d2": {
                "Name": "xxx_nginx_1",
                "EndpointID": "8963a49220e31aadd567f771909e47f43aad4fcb6577a058c7d9a39b0560a602",
                "MacAddress": "02:42:c0:a8:0a:0a",
                "IPv4Address": "192.168.10.10/16",
                "IPv6Address": ""
            },
            "c4bd16a7ca482f7f1f011d923fc694f5a7f7543ecfda3020b1c8009b50260e95": {
                "Name": "xxx_php-fpm_1",
                "EndpointID": "df03ed30398490ff63a03964401e578b0a6fe3e40a9f0af5f3f6689196a45556",
                "MacAddress": "02:42:c0:a8:0a:00",
                "IPv4Address": "192.168.10.0/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "webserver",
            "com.docker.compose.project": "xxx",
            "com.docker.compose.version": "1.29.2"
        }
    }
]

But I use $request->ip() to get the IP and it give me that is 192.168.10.254, it is gateway not what I assign the IP, I am not sure is that correct or not...

@sarukomine sarukomine changed the title Why IP from website is gateway not what I assigned? Why IP from website is gateway that not what I assigned the IP? Jun 24, 2021
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

1 participant