nginx reverse proxy swoole setting problem
First version
php 7.1.0
swoole 2.0.5
nginx 1.10.2
According to the official website instructions http://wiki.swoole.com/wiki/p..., set nginx reverse proxy to swoole,
server {
root /alidata/www/vweb/;
server_name 域名;
location / {
#添加了这个也不行
#try_files $uri $uri/ /index.php?$query_string;
#下面这几行是swoole官网设定
if (!-e $request_filename) {
proxy_pass http://127.0.0.1:9501;
}
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_set_header X-Real-IP $remote_addr;
}
}
There is no problem with the accessed domain name/index.php or domain name/admin/, and the results of swoole code execution can appear (swoole two access records can be seen in the background)
But when accessing domain name directly, 403 appears (you can see swoole printing an access record in the background)
Added try_files $uri $uri/ /index.php?$query_string; in nginx configuration but it has no effect
Please give me some advice!
The swoole code is as follows (just print access records):
$http = new swoole_http_server("127.0.0.1", 9501);
$http->on('request', function ($request, $response) {
echo '-------------------Request---#'.rand(1000, 9999).'------------------'."\n";
$response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});
$http->start();
if(!-e $request_filename)
Only forward to http://127.0.0.1:9501 if this condition is met
Obviously the condition is not met
File and directory judgment
-f and!-f judge whether the file exists
-d and !-d determines whether the directory exists
-e and !-e determine whether the file or directory exists
-x and !-x determine whether the file is executable
You only access the domain name, "/" exists, so it will not be forwarded
As mentioned above, you need to specify a default request file
According to your requirements, there should be a line in server
index index.php;
You can just use Google as your backend.