Skip to content

Instantly share code, notes, and snippets.

@sky93
Last active October 16, 2021 18:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sky93/ca03076ab50f2c322aa8858796f11158 to your computer and use it in GitHub Desktop.
Save sky93/ca03076ab50f2c322aa8858796f11158 to your computer and use it in GitHub Desktop.
Map Laravel /api route to api subdomain in Nginx
server {
listen 80;
server_name api.example.com;
location / {
root /usr/share/nginx/LARAVEL_DIR/public;
index index.php;
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param REQUEST_URI /api$request_uri; #This line is important!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment