简体   繁体   中英

Docker compose container behind nginx proxy cannot access internet

My goal is to set up a reverse proxy to connect to a sentry relay server via ssl. Essentially, the end goal is to forward traffic from a device to sentry.io through sentry relay, and the nginx server is so that this communication be can done through a secure connection.

I have the following docker-compose.yml :

version: '3'
services:
  nginx:
    image: nginx:latest
    container_name: nginx
    volumes:
      - nginx.conf:/etc/nginx/nginx.conf
      - /etc/letsencrypt/:/etc/letsencrypt/
    ports:
      - 80:80
      - 443:443
    networks:
      - relay-network
    environment:
      - ENV=production
      - APPLICATION_URL=http://relay
  relay:
    image: getsentry/relay
    container_name: relay
    command: ["run", "--config", "/etc/relay/"]
    volumes:
      - config/:/etc/relay/
    expose:
      - "80"
    networks:
      - relay-network

networks:
  relay-network:

Through the nginx and relay the logs I can see that I am able to connect to the relay container using an ssl connection. However, all the sentry queries fail due to an invalid project id – I know this to be untrue because when I send messages with the same project id to the real sentry.io (not through my proxy), it works. My intuition is that the sentry relay server is unable to access the inte.net to verify the project id as real, so it tries to look for local project ids, of which there are none.

How can I make sure my relay container can connect to external.networks like sentry.io?

Connect to your relay container interactively with docker exec -it relay bash and try to ping something or load a page with curl . If you want to do that automatically you can use healthcheck .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM