Skip to content

Instantly share code, notes, and snippets.

@Devendra0110
Last active September 13, 2023 12:24
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 Devendra0110/8cba31627e74ef323e6f24781f3ae0e5 to your computer and use it in GitHub Desktop.
Save Devendra0110/8cba31627e74ef323e6f24781f3ae0e5 to your computer and use it in GitHub Desktop.
Nginx Config for React deployment
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