Skip to content

Instantly share code, notes, and snippets.

@ozgurg
Last active February 9, 2022 08:03
Show Gist options
  • Save ozgurg/a64de4672c60b13dbed8888731056417 to your computer and use it in GitHub Desktop.
Save ozgurg/a64de4672c60b13dbed8888731056417 to your computer and use it in GitHub Desktop.
NGINX: Separating client, API, admin (Node.js & React/Vue/etc)
  • / = domain.com (Front-end app)
  • /admin = domain.com/admin (Front-end app)
  • /api = domain.com/api (Node.js, running on 3000 port)
server {
listen 80;
listen [::]:80;
server_name localhost;
index index.html;
root /var/www/client;
location / {
try_files $uri /index.html;
}
location /admin {
root /var/www;
try_files $uri /admin/index.html;
}
location ^~ /api/ {
proxy_pass http://127.0.0.1:3000/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment