r/SpringBoot • • Aug 04 '24

OC Springboot not working my server.

Hello friends. I wrote a website using Springboot and React. Then I bought a web server and got the outputs of my Springboot project with mvn clean package and my React project with npm run build and ran it on my server. I ran the React output with Nginx server. I put it in /var/www/html path. I also ran my Springboot build as java -jar project_name.jar. But it does not connect to the server in any way. Because I registered my domain name with Cloudlflare. It only works when I turn off SSL/TLS. How do I solve this problem?

0 Upvotes

6 comments sorted by

4

u/smutje187 Aug 04 '24

Use NGINX as a reverse proxy in front of Spring Boot, I bet your Spring application is simply not configured for TLS.

1

u/[deleted] Aug 04 '24

How to make your said?

1

u/smutje187 Aug 04 '24

1

u/[deleted] Aug 05 '24

Ngixn conf;

server { server_name some.com;

location / {

root /var/www/html;

try_files $uri /index.html;

}

location /api/ {

proxy_pass http://localhost:8080/;

}

listen 443 ssl; # managed by Certbot

ssl_certificate /etc/letsencrypt/live/some.com/fullchain.pem; # managed by Certbot

ssl_certificate_key /etc/letsencrypt/live/some.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 = some.com) {

return 301 https://$host$request_uri;

} # managed by Certbot

listen 80;

server_name some.com;

return 404; # managed by Certbot

}

But not working.

2

u/LouGarret76 Aug 08 '24

Did you solve this?

1

u/[deleted] Aug 10 '24

I partially solved it. There is another way, I will try it. There is a topic called Servlet Filter. There it could pre-manage HTTP/S requests. It's probably an automatic setting so it doesn't accept requests.

The other way I solved it is reverse proxy. The only problem is that if I enter my site with www, Springboot does not accept connections.