I have the following...
version: '2'
services:
main-nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./nginx/src:/usr/src
ports:
- "80:80"
- "443:443"
ui:
container_name: ui
image: cbusha-ui:latest
be:
container_name: be
image: cbusha-be:latest
ports:
- "8080:8080"
server {
listen 80;
listen 443 ssl;
ssl_certificate /usr/src/site.crt;
ssl_certificate_key /usr/src/site.key;
server_name me.com;
# include /usr/src/allow-cloudflare-only.conf
location /services {
rewrite /services/(.*) /$1 break;
proxy_pass http://be:8080;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header HOST $host/work;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Frame-Options SAMEORIGIN;
}
location / {
proxy_pass http://ui:3000/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Frame-Options SAMEORIGIN;
}
}
When I try to access the backend directly it works fine...
But when I try to use the NGINX proxy I get a 400
What am I missing?
Note the ui works fine so...
Also to be clear the names in the urls such as http://be:8080 is the container name in docker so those have been forwarded to localhost to prove it works but I can also run it directly on the container as is...
Update
So I changed it to
location /services {
proxy_pass http://be:8080/;
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;
}
But I still get a 400 when I call
https://localhost/services/heartbeat
and a 200 when I call
http://localhost:8080/heartbeat



