Last active
February 24, 2022 15:45
-
-
Save KevinBatdorf/c4d274dec22ebb0586d63b97adeb8be1 to your computer and use it in GitHub Desktop.
Config for running NextJS production app on Laravel Forge with WP backend
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
# Deploy script - change the site from default if needed, of course | |
SITE="/home/forge/default" | |
cd $SITE | |
git pull origin $FORGE_SITE_BRANCH | |
# npm ci | |
npm run build | |
pkill -f "node $SITE/node_modules/.bin/next start" |
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
# ... insert around line 30 | |
location / { | |
proxy_pass http://localhost:3000; # Port number of node http server | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
# Specific to allow WP to run off the same server/site | |
# This assumes you have WordPress in a /wp directory, and the wp-content in /content dir | |
rewrite ^/login$ /wp/wp-login.php permanent; | |
location /wp { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location /content { | |
try_files $uri $uri/ /index.php?$query_string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You also need to create a deamon to keep the node server running