Created
March 18, 2024 18:06
-
-
Save majudhu/915e6ff0583aef0011db76dd44cdff00 to your computer and use it in GitHub Desktop.
nginx nextjs expressapi
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 { | |
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