Last active
May 25, 2022 22:10
-
-
Save jamesallan93/3becd1ca19bbdeceb53ceb7847b9780f to your computer and use it in GitHub Desktop.
Nginx for Laravel api and reverse proxy for frontend on same domain
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
| map $sent_http_content_type $expires { | |
| "text/html" epoch; | |
| "text/html; charset=utf-8" epoch; | |
| default off; | |
| } | |
| server { | |
| listen 80; | |
| server_name lorem.io www.lorem.io; | |
| root /home/joedoe/Documents/projects/MY_PROJECT/backend/public; | |
| index index.html index.htm index.php; | |
| location /api/ { | |
| root /home/joedoe/Documents/projects/MY_PROJECT/backend/public; | |
| try_files $uri /index.php$is_args$args; | |
| } | |
| location / { | |
| expires $expires; | |
| proxy_redirect off; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_read_timeout 1m; | |
| proxy_connect_timeout 1m; | |
| proxy_pass http://localhost:3000; # set the address of the Node.js instance here | |
| #try_files $uri /index.html; | |
| } | |
| location ~ \.php$ { | |
| fastcgi_pass unix:/run/php/php8.1-fpm.sock; | |
| fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
| #include fastcgi_params; | |
| include snippets/fastcgi-php.conf; | |
| } | |
| location ~ /\.ht { | |
| deny all; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment