Am două configurații de backend laravel pe rute diferite. și există un spa pe rădăcină. acum vreau să setez un server websocket împreună cu el.
aici este site-ul meu.conf
Server {
asculta 80;
numele serverului _;
rădăcină /var/www/html/abc.xyz;
add_header X-Frame-Options „SAMEORIGIN”;
add_header X-Content-Type-Options "nosniff";
index index.html index.php;
Locație / {
try_files $uri /index.html ;
}
set de caractere utf-8;
locație = /favicon.ico {
access_log off; log_not_found off;
}
locație = /robots.txt {
access_log off; log_not_found off;
}
Server {
asculta 80;
numele serverului _;
rădăcină /var/www/html/abc.xyz;
add_header X-Frame-Options „SAMEORIGIN”;
add_header X-Content-Type-Options "nosniff";
index index.html index.php;
Locație / {
try_files $uri /index.html ;
}
set de caractere utf-8;
locație = /favicon.ico {
access_log off; log_not_found off;
}
locație = /robots.txt {
access_log off; log_not_found off;
}
locație /backend {
alias /var/www/html/abc.xyz/backend;
try_files $uri $uri/ @backend;
locație ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
locație @backend {
rescrie ^/backend/(.*)$ /backend/index.php ultima;
}
locație /api {
alias /var/www/html/abc.xyz/api;
try_files $uri $uri/ @api;
locație ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
locație @api {
rescrie /api/(.*)$ /api/index.php?/$1 ultimul;
}
locație /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
locație ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
includ /etc/nginx/fastcgi_params;
}
locație ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
locație /ws* {
proxy_pass http://127.0.0.1:6001;
proxy_set_header Gazdă $gazdă;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect dezactivat;
proxy_http_versiunea 1.1;
proxy_set_header Actualizare $http_upgrade;
proxy_set_header Conexiune „upgrade”;
proxy_set_header Gazdă $gazdă;
proxy_cache_bypass $http_upgrade;
}
locație ~ /\.(?!cunoscut).* {
nega totul;
}
}
cel locație /ws
blocul este preluat din documentația laravel websockets. dar acest bloc de locație dă eroarea 404 negăsit. dar această configurație nginx nu funcționează. Proiectul meu de site web laravel funcționează bine pe localhost.
Editați | ×
aceasta este rezultatul lsof -i :80.443.6001
COMANDA PID UTILIZATOR TIP FD DIMENSIUNEA DISPOZITIV/OPRIT NUMELE NODULUI
php 414490 root 5u IPv4 5974385 0t0 TCP *:x11-1 (ASCULTATE)
php 414490 root 6u IPv4 5991457 0t0 TCP localhost.localdomain:x11-1->localhost.localdomain:35684 (STABILIT)
nginx 415533 root 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415533 root 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415534 www-data 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415534 www-data 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415535 www-data 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415535 www-data 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415536 www-data 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415536 www-data 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415537 www-data 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415537 www-data 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415538 www-data 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415538 www-data 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415539 www-data 6u IPv4 5990824 0t0 TCP *:https (ASCULTATE)
nginx 415539 www-data 7u IPv4 5990825 0t0 TCP *:http (ASCULTATE)
nginx 415539 www-data 8u IPv4 5985866 0t0 TCP linux:https->157.42.56.21:55728 (STABILIT)
nginx 415539 www-data 12u IPv4 5985868 0t0 TCP localhost.localdomain:35684->localhost.localdomain:x11-1 (STABILIT)