I’m using nginx to proxy my fly apps. This is my dev nginx config. I’m using docker compose to keep them in the same network.
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
# prevent css, js files sent as text/plain objects
include /etc/nginx/mime.types;
server {
listen 443 ssl;
client_max_body_size 10M;
ssl_certificate /etc/nginx/ssl/localhost.crt;
ssl_certificate_key /etc/nginx/ssl/localhost.key;
location / {
proxy_pass http://client:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api {
proxy_set_header Host $http_host;
proxy_pass http://server:8000;
}
location /admin {
# Copy the same as /api
proxy_set_header Host $http_host;
proxy_pass http://server:8000;
}
location /static/ {
proxy_pass http://server:8000;
autoindex on;
autoindex_exact_size off;
}
}
}
This is my nginx for deployment:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
# prevent css, js files sent as text/plain objects
include /etc/nginx/mime.types;
server {
listen 443;
listen [::]:443;
client_max_body_size 10M;
location / {
proxy_pass https://client.fly.dev/;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_ssl_server_name on;
}
location /api {
proxy_set_header Host $http_host;
proxy_pass https://server.fly.dev;
proxy_ssl_server_name on;
}
location /admin {
# Copy the same as /api
proxy_set_header Host $http_host;
proxy_pass https://server.fly.dev;
proxy_ssl_server_name on;
}
location /static/ {
proxy_pass https://server.fly.dev;
autoindex on;
autoindex_exact_size off;
proxy_ssl_server_name on;
}
}
}
- since I’m making different apps they are on differnet domain names which causes cors errors. how can i fix this?