I have supertokens core behind nginx reverse proxy...
# support-questions-legacy
n
I have supertokens core behind nginx reverse proxy. I'm forwarding these headers: 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; I get "hello" only if i remove the Host header. So I'm wondering how to bind the core instance with the A/AAAA assigned record. In the attached docs I found SUPERTOKENS_HOST but it doesnt seem to have effect on the reverse proxy, still getting HTTP Status 400 – Bad Request when forwarding the host. this is my config.yaml core_config_version: 0 host: "0.0.0.0" supertokens_host: "https://supertokens.example.com"
r
hey @nik2208.2208 are you able to query the hello API of the core?
n
of course, as mentioned, I get "hello" feedback only if i do not forward the requesting host.
r
whats the core error stack when you get a 400?
n
if i set this header proxy_set_header Host $host; in the reverse proxy (nginx) i get 400
r
oh, so this is an nginx config issue?
n
i dont know actually, there's the SUPERTOKENS_HOST env paramenter that should serve to this, i'm wondering if it is needed or not.
in case of reverse proxy the original host requested should be passed to the server (our supertokens core in this case)
r
if the 400 error is from nginx, it's an nginx config issue
n
i understand ur point. Please, try to undestand mine. I'm able to make it work, and It works, actually. I'm also adding a paramenter in my reverse proxy, and it seems that in supertokens env variable the option to set the name of the domain server is something possible. It would be a security improvement because it would avoid to reach the instance in case the server would be tampered with
forcing the instance to accept request referred only to the specified host
but, and this is what im trying to explain, if i do not forward the host (and so supertokens core would receive the request always from the reverse proxy's ip to the supertokens ip address, not to its domain name) everything works fine. If instead I do what should be done (forwarding the requested host) i get 400 bad request. Is this normal? is this intented? is this the way supertokens core is supposed to work? Or maybe is the ENV variable not being considered (i'm setting it in config.yaml, running supertokens in a docker container) and so the error I get is because of a mismatching from supertokens' ip and domain name?
r
Are you using docker?
n
yes
r
then the value of SUPERTOKENS_HOST should be 0.0.0.0, and you can bind your docker container to a specific host.
n
host variable should be set to 0.0.0.0 as reported here https://github.com/supertokens/supertokens-docker-postgresql#using-custom-config-file , whats the meaning of setting SUPERTOKENS_HOST also to 0.0.0.0? are they the same variable?
16 Views