N
Novu6mo ago
Victor

Self Hosting: Problems with Nginx reverse proxy

I've read two previous posts on this however I can't get reverse proxying working for novu. I am using nginx with the following config: https://hastebin.skyra.pw/edufimigej.nginx with the following env variables (a bit verbose but I'm really not sure where the issue lies)
HOST_NAME=https://novu.domain.com
API_PORT=3000
REDIS_PORT=6379
REDIS_CACHE_SERVICE_PORT=6379
WS_PORT=3002
REACT_APP_WS_URL=$HOST_NAME:3002
API_ROOT_URL=$HOST_NAME/api
DISABLE_USER_REGISTRATION=false
FRONT_BASE_URL=$HOST_NAME:4200
WIDGET_EMBED_PATH=$HOST_NAME:4701/embed.umd.min.js
WIDGET_URL=$HOST_NAME/widget
# GLOBAL_CONTEXT_PATH=
# WEB_CONTEXT_PATH=
API_CONTEXT_PATH=api
WS_CONTEXT_PATH=ws
WIDGET_CONTEXT_PATH=widget
HOST_NAME=https://novu.domain.com
API_PORT=3000
REDIS_PORT=6379
REDIS_CACHE_SERVICE_PORT=6379
WS_PORT=3002
REACT_APP_WS_URL=$HOST_NAME:3002
API_ROOT_URL=$HOST_NAME/api
DISABLE_USER_REGISTRATION=false
FRONT_BASE_URL=$HOST_NAME:4200
WIDGET_EMBED_PATH=$HOST_NAME:4701/embed.umd.min.js
WIDGET_URL=$HOST_NAME/widget
# GLOBAL_CONTEXT_PATH=
# WEB_CONTEXT_PATH=
API_CONTEXT_PATH=api
WS_CONTEXT_PATH=ws
WIDGET_CONTEXT_PATH=widget
Ran the docker containers. After navigating to novu.domain.com I get a 502 from Cloudflar.e.
6 Replies
Ask Inkeep
Ask Inkeep6mo ago
Hi @Victor, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question.
Novu_Bot
Novu_Bot6mo ago
@Victor, you just advanced to level 1!
Ask Inkeep
Ask Inkeep6mo ago
----------------------------- While I generate an answer, here are some sources that might be helpful: * Deploy with Docker * Run Novu in local machine * How to send notifications with Next.js and React email * AWS ----------------------------- Answer It appears you are having challenges setting up reverse proxying for Novu with Nginx. Here are a few tips and an example configuration to help guide you: 1. Ensure Context Paths: Make sure the context paths in your .env file align with those in your Nginx configuration. 2. Correct Proxies: Your Nginx configuration should properly route requests to the correct backend services. Here's an example .env configuration:
HOST_NAME=https://novu.domain.com
API_PORT=3000
REDIS_PORT=6379
REDIS_CACHE_SERVICE_PORT=6379
WS_PORT=3002
REACT_APP_WS_URL=$HOST_NAME/ws
API_ROOT_URL=$HOST_NAME/api
DISABLE_USER_REGISTRATION=false
FRONT_BASE_URL=$HOST_NAME
WIDGET_EMBED_PATH=$HOST_NAME/widget/embed.umd.min.js
WIDGET_URL=$HOST_NAME/widget
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
API_CONTEXT_PATH=api
WS_CONTEXT_PATH=ws
WIDGET_CONTEXT_PATH=widget
HOST_NAME=https://novu.domain.com
API_PORT=3000
REDIS_PORT=6379
REDIS_CACHE_SERVICE_PORT=6379
WS_PORT=3002
REACT_APP_WS_URL=$HOST_NAME/ws
API_ROOT_URL=$HOST_NAME/api
DISABLE_USER_REGISTRATION=false
FRONT_BASE_URL=$HOST_NAME
WIDGET_EMBED_PATH=$HOST_NAME/widget/embed.umd.min.js
WIDGET_URL=$HOST_NAME/widget
GLOBAL_CONTEXT_PATH=
WEB_CONTEXT_PATH=
API_CONTEXT_PATH=api
WS_CONTEXT_PATH=ws
WIDGET_CONTEXT_PATH=widget
(1) , (2) , (3) , (4) And an example Nginx configuration:
Ask Inkeep
Ask Inkeep6mo ago
server {
server_name novu.domain.com;
listen 80;

location / {
proxy_pass http://localhost:4200/;
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;
}

location /api {
proxy_pass http://localhost: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;
}

location /ws {
proxy_pass http://localhost:3002/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}

location /widget {
proxy_pass http://localhost:4500/;
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 {
server_name novu.domain.com;
listen 80;

location / {
proxy_pass http://localhost:4200/;
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;
}

location /api {
proxy_pass http://localhost: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;
}

location /ws {
proxy_pass http://localhost:3002/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}

location /widget {
proxy_pass http://localhost:4500/;
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;
}
}
(1) , (2) , (3) , (4) Make sure your .env file correctly matches the paths specified in your Nginx configuration and that Nginx is correctly routing requests. The configuration above should help ensure that requests are correctly proxied to the various Novu services.
Victor
VictorOP6mo ago
Going to reconfigure the env file & config as per above first.
Ask Inkeep
Ask Inkeep6mo ago
Glad I could be helpful. Feel free to create a new thread with any new questions you may have.
Want results from more Discord servers?
Add your server