Last active
October 16, 2021 18:58
-
-
Save sky93/ca03076ab50f2c322aa8858796f11158 to your computer and use it in GitHub Desktop.
Map Laravel /api route to api subdomain in Nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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