【发布时间】:2020-08-07 15:23:25
【问题描述】:
我确实阅读并尝试了以下内容;
- https://stackoverflow.com/a/46286973/8068675 听 = 127.0.0.1:9000;
- https://stackoverflow.com/a/50615652/8068675 禁用缓冲
- https://github.com/microsoft/WSL/issues/393#issuecomment-442498519 禁用缓冲 + 不同的配置
但这些都没有解决问题。
问题
从 Windows;当我通过http://myproject.test、https://myproject.test 或127.0.0.1 浏览位于 WSL2 的网站时,前 2-3 个请求正在快速进行(
Windows 10 上的配置
- 防火墙已禁用
-
127.0.0.1 myproject.test添加到C:\Windows\System32\drivers\etc\hosts - mkcerts 已安装
- 安装了 Ubuntu 20.04 的 WSL 2
WSL 2 上的配置
- Ubuntu 20.04
- nginx 1.18
- mysql 8.0
- php-fpm 7.4
项目
- Laravel
- 位置
/home/clement/projects/myproject/ - 证书(使用 mkcert 生成)
/home/clement/projects/certs/ - 所有者:
clement:www-data - 权限:
777(仅用于测试和开发目的)
/etc/nginx/sites-available/myproject.test
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /home/clement/projects/certs/myproject.test.pem;
ssl_certificate_key /home/clement/projects/certs/myproject.test-key.pem;
client_max_body_size 108M;
access_log /var/log/nginx/application.access.log;
server_name myproject.test;
root /home/clement/projects/myproject/public;
index index.php;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ \.php$ {
fastcgi_buffering off;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
include fastcgi_params;
}
}
我在使用fastcgi_pass 127.0.0.1:9000; 或fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; 时遇到同样的问题
当我在项目中执行php -S localhost:8080 或php artisan serve 时,一切正常。
使用日志编辑
这是我在 nginx 上获得的日志,但即使有了这些信息,我仍然找不到任何解决问题的资源。
2020/08/07 23:06:30 [错误] 1987#1987: *6 上游超时(110:连接超时),同时读取上游,客户端:127.0.0.1,服务器:myproject.test,请求: “GET /_debugbar/assets/javascript?v=1588748787 HTTP/1.1”,上游:“fastcgi://unix:/run/php/php7.4-fpm.sock:”,主机:“myproject.test”,推荐人: "http://myproject.test/"
或者使用IP
2020/08/08 01:43:01 [错误] 4080#4080: *4 上游超时(110:连接超时),同时读取上游,客户端:127.0.0.1,服务器:myproject.test,请求: “GET / HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“myproject.test”
【问题讨论】:
标签: nginx windows-subsystem-for-linux wsl-2