I have Spring Boot Backend running in port 8080 on my server. I want to serve static files on the same server. The server has a domain in it. Based on my Nginx configuration, the domain is showing 127.0.0.1:8080. I want to access a file in the server using example.com/file/filename.
Here is my Nginx configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
location /file/ {
root /home/ubuntu/file;
autoindex on;
}
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# SSL Configuration Here
}
Using this configuration, every time I tried to access example.com/file. It always redirects to the example.com, the spring boot project jar. Is there any solution to this problem, or do I have to put the file inside the project jar?