Skip to content

Instantly share code, notes, and snippets.

@ardani
Forked from sky93/api.example.conf
Created April 27, 2021 11:01
Show Gist options
  • Save ardani/3b9912afb1e02efea1b87759a602db95 to your computer and use it in GitHub Desktop.
Save ardani/3b9912afb1e02efea1b87759a602db95 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