Skip to content

Instantly share code, notes, and snippets.

@npthao1312
Created December 25, 2020 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npthao1312/94cfb3b7558bbab7b5c19ebfde5697a3 to your computer and use it in GitHub Desktop.
Save npthao1312/94cfb3b7558bbab7b5c19ebfde5697a3 to your computer and use it in GitHub Desktop.
Nginx config file to run ReactJS app and Spring Boot app separately in the same domain
server {
listen 80;
server_name ip example.com www.example.com;
# 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