Last active
September 13, 2023 12:24
-
-
Save Devendra0110/8cba31627e74ef323e6f24781f3ae0e5 to your computer and use it in GitHub Desktop.
Nginx Config for React deployment
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
Go to serving location and create build folder - | |
cd /var/www | |
mkdir build | |
Go to project location, create build and copy it to the serving location | |
npm run build | |
scp -r ./build/* /var/www/build | |
Go to the nginx conf location and open default- | |
cd /etc/nginx/sites-available | |
sudo nano default | |
Update the below code in it - | |
GNU nano 6.2 default | |
# nginx congifuration script | |
server { | |
listen 0.0.0.0:80; | |
server_name _; | |
root /var/www/build; | |
index index.html index.htm; | |
try_files $uri /index.html; | |
# Static files | |
location / { | |
try_files $uri $uri/ = 404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment