nginx reverse proxy swoole settings
習慣沉默
習慣沉默 2017-05-16 17:08:26
0
3
954

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;    
    }
}
  1. 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)

  2. But when accessing domain name directly, 403 appears (you can see swoole printing an access record in the background)

  3. 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();
習慣沉默
習慣沉默

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!