Hi i have google cloud vm, i have a domain that serves my app,
now i create another ngnix server configuration for my hasura console,
My app works fine on my domain,
but when i try
https://mydomain:8080
http://mydomain:8080 etc
i cant be able to reach hasura console;
Also on GCP all my ports are open and accessible.
this is my docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
003e86e139a0 hasura/graphql-engine:v2.38.0 "/bin/sh -c '"${HGE_…" 3 hours ago Up 12 minutes (healthy) 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp MYDOMAIN-hasura-graphql-engine-1
0ce2c666d641 postgres:15 "docker-entrypoint.s…" 4 days ago Up 12 minutes 5432/tcp MYDOMAIN-hasura-postgres-1
6991009d52e6 MYDOMAIN:latest "/nodejs/bin/node bu…" 5 days ago Up 5 days 3000/tcp bold_elion
This is my sites-avaliable domain configuration
GNU nano 7.2
server {
server_name MYDOMAIN.com;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/wepiik.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/wepiik.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://172.17.0.2:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
if ($host = MYDOMAIN.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name MYDOMAIN.com;
return 404; # managed by Certbot
}
server {
server_name hasura_MYDOMAIN;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/wepiik.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/wepiik.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://172.18.0.2:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
and this is my hasura docker compose
GNU nano 7.2
services:
postgres:
image: postgres:15
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: MYPASSWORD
graphql-engine:
image: hasura/graphql-engine:v2.38.0
ports:
- "8080:8080"
restart: always
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
HASURA_GRAPHQL_ADMIN_SECRET: MYSECRET
PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
HASURA_GRAPHQL_METADATA_DEFAULTS: '{"backend_configs":{"dataconnector":{"athena":{"uri":"http://data-connector-agent:8081/api/v1/athena"},"mariadb":{"uri":"http://data>
volumes:
db_data:
2
Answers
All configurations were true. I added a firewall rule with ip range 0.0.0.0, instead of 0.0.0.0/0 that was the all problem. Consider your firewall rules if you face with the same issue.
Your configuration
proxy_pass http://172.18.0.2:8080;
assumes that this IP address corresponds to the internal Docker IP of the Hasura container. However, Docker typically assigns IP addresses to containers dynamically. This means that each time the container restarts, it might be assigned a new IP address, making the static IP setting in Nginx ineffective.I suggest using the service name defined in Docker Compose to connect to Hasura. For example, if the Hasura service in Docker Compose is called graphql-engine, then you can use this alias as the hostname in Nginx:
This service name will automatically be resolved to the current IP address within the Docker network.