Nginx proxy config for jar project

05.02.2022 | 509 | SQL

An example of using the nginx web server as a proxy server for issuing local resources and proxying requests to a running jar application

We create a config:
nano /etc/nginx/sites-available/spring.local.conf
server {    listen 80;    server_name spring.local;     # serve static files    location ~ ^/(img|css|js|file)/  {        root    /var/www/spring.local/public;        #expires 30d;    }        location / {            proxy_pass http://localhost:8080/;            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            proxy_set_header X-Forwarded-Proto $scheme;            proxy_set_header X-Forwarded-Port $server_port;    } }
Turn on the config:
ln -s /etc/nginx/sites-available/spring.local.conf /etc/nginx/sites-enabled/
Restart the web server:
systemctl restart nginx.service



← Back

Comments (0)