diff --git a/config/autoload/mercure.local.php.dist b/config/autoload/mercure.local.php.dist index c760e771..b10ad86e 100644 --- a/config/autoload/mercure.local.php.dist +++ b/config/autoload/mercure.local.php.dist @@ -5,8 +5,8 @@ declare(strict_types=1); return [ 'mercure' => [ - 'public_hub_url' => 'http://localhost:3080', - 'internal_hub_url' => 'http://shlink_mercure', + 'public_hub_url' => 'http://localhost:8001', + 'internal_hub_url' => 'http://shlink_mercure_proxy', 'jwt_secret' => 'mercure_jwt_key', ], diff --git a/data/infra/mercure_proxy_vhost.conf b/data/infra/mercure_proxy_vhost.conf new file mode 100644 index 00000000..df986b37 --- /dev/null +++ b/data/infra/mercure_proxy_vhost.conf @@ -0,0 +1,17 @@ +server { + listen 80 default_server; + + error_log /home/shlink/www/data/infra/nginx/mercure_proxy.error.log; + + location / { + proxy_pass http://shlink_mercure; + proxy_read_timeout 24h; + proxy_http_version 1.1; + proxy_set_header Connection ""; + + ## Be sure to set USE_FORWARDED_HEADERS=1 to allow the hub to use those headers ## + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 51a8a83b..ec56b883 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: '3' services: shlink_nginx: container_name: shlink_nginx - image: nginx:1.17.6-alpine + image: nginx:1.17.10-alpine ports: - "8000:80" volumes: @@ -28,6 +28,7 @@ services: - shlink_db_ms - shlink_redis - shlink_mercure + - shlink_mercure_proxy environment: LC_ALL: C @@ -49,6 +50,7 @@ services: - shlink_db_ms - shlink_redis - shlink_mercure + - shlink_mercure_proxy environment: LC_ALL: C @@ -105,6 +107,17 @@ services: ports: - "6380:6379" + shlink_mercure_proxy: + container_name: shlink_mercure_proxy + image: nginx:1.17.10-alpine + ports: + - "8001:80" + volumes: + - ./:/home/shlink/www + - ./data/infra/mercure_proxy_vhost.conf:/etc/nginx/conf.d/default.conf + links: + - shlink_mercure + shlink_mercure: container_name: shlink_mercure image: dunglas/mercure:v0.8 @@ -113,3 +126,4 @@ services: environment: CORS_ALLOWED_ORIGINS: "*" JWT_KEY: "mercure_jwt_key" + USE_FORWARDED_HEADERS: "1"