Skip to content

Instantly share code, notes, and snippets.

@unr
Created February 27, 2019 18:09
Show Gist options
  • Save unr/3138bc7fb54faa8716b445aca2ffd63a to your computer and use it in GitHub Desktop.
Save unr/3138bc7fb54faa8716b445aca2ffd63a to your computer and use it in GitHub Desktop.
Example Nginx file for a Laravel/Nuxt php server locally. Production runs something similar, but more complex with load balancers.
server {
listen 80;
server_name site.com www.site.com *.site.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name site.com www.site.com *.site.com;
root /;
charset utf-8;
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
internal;
alias /;
try_files $uri $uri/;
}
ssl_certificate /Users/unr/.valet/Certificates/site.com.crt;
ssl_certificate_key /Users/unr/.valet/Certificates/site.com.key;
location / {
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://$server_addr:3000;
}
location ^~ /admin {
try_files $uri @admin;
}
location @admin {
proxy_pass http://$server_addr:3333;
}
location @nuxt {
proxy_pass http://$server_addr:3000;
}
location ^~ /app/ {
rewrite ^ /Users/unr/.composer/vendor/laravel/valet/server.php last;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /Users/unr/.valet/Log/nginx-error.log;
error_page 404 /Users/unr/.composer/vendor/laravel/valet/server.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/Users/unr/.valet/valet.sock;
fastcgi_index /Users/unr/.composer/vendor/laravel/valet/server.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /Users/unr/.composer/vendor/laravel/valet/server.php;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment