Rumah > Artikel > rangka kerja php > Kongsi konfigurasi nginx Laravel Octane dan WebSocket dalam Laradock
Artikel ini membawakan anda pengetahuan yang berkaitan tentang Laravel, yang kebanyakannya merekodkan konfigurasi nginx Laravel Octane dan WebSocket dalam Laradock Bagi mereka yang berminat, lihat di bawah saya harap ia akan membantu anda.
docker 安装laradock,和Laravel Octane的安装这里就不过多赘述了。
Penerangan sebelumnya
Swoole selepas memasang Laravel Octane dalam laradock
Mula, konfigurasikan sambungan capaian port dalam nginx dan gagal, mesej ralat 502, konfigurasi adalah seperti berikut:
location /octane { proxy_pass http://127.0.0.1:8080;}
Sebab: Pelayan Swoole berjalan dalam bekas Ruang Kerja berjalan dalam bekas Nginx, anda perlu mencari IP Ruang Kerja dan dikonfigurasikan dalam nginx.
Penyelesaian
docker ps
Lihat id bekas Ruang Kerja.
docker inspect 容器id
, cari Networks
dalam IPAddress
.
Ubah suai fail konfigurasi nginx.
map $http_upgrade $connection_upgrade { default upgrade; '' close;}
upstream ws { server 172.22.0.4:9502 weight=5 max_fails=3 fail_timeout=30s;}
location /ws { set $suffix ""; if ($uri = /index.php) { set $suffix ?$query_string; } proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header SERVER_PORT $server_port; proxy_set_header REMOTE_ADDR $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://ws$suffix;}
Mulakan semula nginx.
Fail konfigurasi
map $http_upgrade $connection_upgrade { default upgrade; '' close;}upstream ws { server 172.22.0.4:9502 weight=5 max_fails=3 fail_timeout=30s;}server { listen 80; listen [::]:80; server_name bbs.test; root /var/www/laravel/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fixes timeouts fastcgi_read_timeout 600; include fastcgi_params; } location ~ /\.ht { deny all; } location /.well-known/acme-challenge/ { root /var/www/letsencrypt/; log_not_found off; } location /ws { set $suffix ""; if ($uri = /index.php) { set $suffix ?$query_string; } proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header SERVER_PORT $server_port; proxy_set_header REMOTE_ADDR $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://ws$suffix; } error_log /var/log/nginx/laravel_error.log; access_log /var/log/nginx/laravel_access.log;}
Pembelajaran yang disyorkan: "tutorial video laravel"
Atas ialah kandungan terperinci Kongsi konfigurasi nginx Laravel Octane dan WebSocket dalam Laradock. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!