In my quest to get a better understanding of reactive programming I created a little app that has two endpoints a POST and a GET. The POST method saves some data to MongoDB Atlas and the GET method returns the data from the DB.
The workflow: GET Request via a browser --> POST some new data via curl --> the new data gets displayed in the browser.
The workflow works locally but as soon as I add NGINX in the mix the workflow stops working. No data is displayed and the connection is being terminated after some time.
My Controller:
@GetMapping(value = "mda", produces = MediaType.APPLICATION_STREAM_JSON_VALUE)
public Flux<ResponseData> getAll(){
return repo.findBy();
}
My repo method:
@Tailable
Flux<ResponseData> findBy();
How must I change my NGINX conf to make the app work?
My NGINX Config. I changed the original domain:
server {
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
location /reactive/data {
proxy_pass http://localhost:8081/data;
proxy_redirect off;
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 https;
}
location /reactive/mda {
proxy_pass http://localhost:8081/mda;
proxy_redirect off;
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 https;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.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
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 404; # managed by Certbot
}
For completion: The /data endpoint contains the POST and GET (NO @Tailable) and they both work with and without NGINX.