Level 75
See https://gist.github.com/mreschke/27bfafb84add38d3bab8 Has api example setup.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone. Whats the proper way to configure nginx with laravel api. all my routes located in routes/api.php and they are all apiResouces; But now i'm getting 404 with html while making any http req.
upstream api {
server 194.xx.xx.xx;
}
server {
listen 81 default_server;
listen [::]:81 default_server;
error_log /var/log/nginx/backend-error.log error;
access_log /var/log/nginx/backend.log;
server_name api.mysite.com;
location / {
proxy_pass http://api;
}
}
.env
APP_URL=http://api.mysite.com/
nginx/1.14.0 (Ubuntu)
P.s frontend on the same server works fine (another var/www/ folder and nginx config)
Please or to participate in this conversation.