Created
March 11, 2020 11:07
-
-
Save pavelsalauyou/4d22e398e3607e9d3bfcf9382593ef93 to your computer and use it in GitHub Desktop.
Configuring nginx to serve an Angular 8+ project with a Symfony 4 (or 5) backend project in a subdirectory
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 { | |
| server_name example.com; | |
| root /var/www/example.com/dist/example; | |
| try_files $uri $uri/ /index.html; | |
| location /backend { | |
| alias /var/www/example.com/backend/public; | |
| try_files $uri $uri/ @backend; | |
| location ~ ^/backend/index\.php(/|$) { | |
| fastcgi_pass 127.0.0.1:9000; | |
| fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
| include snippets/fastcgi-php.conf; | |
| fastcgi_param SCRIPT_FILENAME $request_filename; | |
| internal; | |
| } | |
| } | |
| location @backend { | |
| rewrite /backend/(.*)$ /backend/index.php?/$1 last; | |
| } | |
| location ~ \.php$ { | |
| return 404; | |
| } | |
| error_log /var/log/nginx/example_com_error.log; | |
| access_log /var/log/nginx/example_com_access.log; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment