Skip to content

Instantly share code, notes, and snippets.

@majudhu
Created March 18, 2024 18:06
Show Gist options
  • Save majudhu/915e6ff0583aef0011db76dd44cdff00 to your computer and use it in GitHub Desktop.
Save majudhu/915e6ff0583aef0011db76dd44cdff00 to your computer and use it in GitHub Desktop.
nginx nextjs expressapi
server {
server_name example.com;
client_max_body_size 100M; # allow huge uploads, upto 100MB
root /home/pm2/nextapp/public; # serve static files from public dir with nginx
try_files $uri @next; # serve static files with nginx, fallback to nextjs on not found
location @next {
include proxy_params;
proxy_pass http://127.0.0.1:3000;
}
location /api {
include proxy_params;
proxy_pass http://127.0.0.1:3000;
}
location /images/ {
root /home/pm2/express-api/public/;
}
}
server {
server_name www.example.com;
listen 80;
return 301 https://example.com;
}
#server {
# listen 80;
# server_name example.com www.example.com;
# return 301 https://example.com$request_uri;
#}
#server {
# listen 80 default_server;
# server_name _;
# return 301 https://example.com;
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment