Gitlab won't work when the external_url is set

I'm trying to setup gitlab with docker, when I set the external_url to git.mydomain.com nothing works (502 Bad Gateway), but when I comment external_url in the gitlab.rb file I can acces my gitlab instance with the IP.

Here is my docker-compose.yml :

version: '2'

services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: 'git.mydomain.com'
    ports:
      - '4280:80'
      - '4443:443'
      - '4222:22'
    volumes:
      - './config:/etc/gitlab'
      - './logs:/var/log/gitlab'
      - './data:/var/opt/gitlab'

Here is my nginx conf :

server {
	listen 80;
	server_name git.mydomain.com;

	location / {
		proxy_pass http://localhost:4280;
		proxy_set_header X-Real-IP $remote_addr;
	}

	return 301 https://$server_name$request_uri;

	location /.well-known/acme-challenge {
		root /var/www/letsencrypt;
	}
}

server {
	server_name www.git.mydomain.com;
	return 301 $scheme://git.mydomain.com$request_uri;
}

server {
	listen 443;
	server_name git.mydomain.com;
	ssl on;

	ssl_certificate /etc/letsencrypt/live/git.mydomain.com/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/git.mydomain.com/privkey.pem;

	location / {
		proxy_pass http://localhost:4280;
		proxy_set_header X-Real-IP $remote_addr;
	}
}