Skip to content

Instantly share code, notes, and snippets.

@KevinBatdorf
Last active February 24, 2022 15:45
Show Gist options
  • Save KevinBatdorf/c4d274dec22ebb0586d63b97adeb8be1 to your computer and use it in GitHub Desktop.
Save KevinBatdorf/c4d274dec22ebb0586d63b97adeb8be1 to your computer and use it in GitHub Desktop.
Config for running NextJS production app on Laravel Forge with WP backend
# 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"
# ... 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;
}
@KevinBatdorf
Copy link
Author

You also need to create a deamon to keep the node server running

Screen Shot 2021-06-18 at 11 52 08 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment