npm run build
npm run start
location / {
try_files $uri $uri/ /index.php?$args;
}
↓ / と /_next/ 以下を表示できるようにします。
location @nextserver {
proxy_pass http://localhost:3000;
add_header X-Custom-HeaderNextServer "Value for Custom Header @nextserver";
}
location ^~ /_next {
try_files $uri @nextserver;
expires 365d;
add_header Cache-Control 'public';
}
location / {
try_files $uri $uri.html /index.html @nextserver;
}
nginx -s reload
シンボリックリンクを貼ればOKです
ln -s /PATH/TO/YOUR/APP/public /PATH/TO/YOUR/WEB-SITE/DocumentRoot
以上でokです
Next.js とphpを使用できるように下記の仕様とします
「/php/<ファイル名>でアクセスした場合」→ /home/YOUR/SERVER/PATH/DocumentRoot/php/<ファイル名>を返す
「/でアクセスした場合」→ next.jsを返す
location /php/ {
alias /home/YOUR/SERVER/PATH/DocumentRoot/php/;
index index.html index.htm;
}
location / {
# Next.js Server
proxy_pass http://localhost:3000;
}