Skip to content

Instantly share code, notes, and snippets.

@matudelatower
Last active November 28, 2019 21:13
Show Gist options
  • Save matudelatower/52b47f8106dc0f576a305dc3777dcbd7 to your computer and use it in GitHub Desktop.
Save matudelatower/52b47f8106dc0f576a305dc3777dcbd7 to your computer and use it in GitHub Desktop.
NGINX, Laravel, Laravel WebSocket, angular front configuration
map $http_upgrade $type {
default "frontend";
websocket "ws";
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name test.project.com;
root /var/www/html/frontend/dist/project-frontend;
index index.html index.php;
location /backend {
alias /var/www/html/project/public;
try_files $uri $uri/ @backend;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @backend {
rewrite /backend/(.*)$ /backend/index.php?/$1 last;
}
location / {
try_files /nonexistent @$type;
#alias /var/www/html/frontend/dist/project-frontend;
#index index.html;
#try_files $uri $uri/ /index.html;
#try_files $uri $uri/ @frontend;
}
location @frontend {
try_files $uri $uri/ /index.html?$query_string;
}
location @ws {
proxy_pass http://127.0.0.1:6001;
proxy_set_header Host $host;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
# Allow the use of websockets
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;
}
ssl_certificate /etc/letsencrypt/live/test.project.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.project.com/privkey.pem; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment