Skip to content

Instantly share code, notes, and snippets.

@ansidev
Last active July 28, 2020 18:07
Show Gist options
  • Save ansidev/9b47f7c075d1ce3c24294bb5a99c88fc to your computer and use it in GitHub Desktop.
Save ansidev/9b47f7c075d1ce3c24294bb5a99c88fc to your computer and use it in GitHub Desktop.
NGINX Configuration for Laravel + NuxtJS
server {
listen 80 default_server;
server_name example.com www.example.com
server_name dev ipv6only=on;
index index.php;
charset utf-8;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api {
# alias /var/www/html/example.com/public;
# try_files $uri $uri/ @backend;
# location ~ \.php {
# fastcgi_pass unix:/run/php-fpm/www.sock;
# fastcgi_param SCRIPT_FILENAME /var/www/html/example.com/public/index.php;
# include /etc/nginx/fastcgi_params;
# }
proxy_redirect http://localhost:8080/ /api;
proxy_pass http://localhost:8080;
}
# location @backend {
# rewrite /api/(.*)$ /api/index.php?/$1 last;
# }
}
server {
listen 8080;
# server_name example.com;
root /var/www/html/example.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment