Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Nginx config file to run ReactJS app and Spring Boot app separately in the same domain
server {
listen 80;
server_name ip;
# note that I don't use https
# serves front end reactjs app
location / {
root /home/user/react-folder/build;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
# serves back end spring boot app default port 8080
location ^~ /api/ {
proxy_pass http://localhost:8080/api/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
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;
proxy_cache_bypass $http_upgrade;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment