Created
December 25, 2020 19:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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