| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
edison1221
9年前发布

just a tiny & fast static and fastcgi reverse proxy written in golang

来自: https://github.com/alash3al/xerver

xerver v2.0

just a light and fast reverse proxy for fastcgi based processes .

Features

  • Cross platform .
  • Accelerated and optimized without modules hell.
  • No configurations needed .
  • Standalone, Tiny & Lightweight .
  • Supports both http and https .
  • Automatically use HTTP/2 "in https" .
  • Control the whole webserver just with your preferred programming language .
  • Tell xerver to perform some operations using http-headers, i.e "send-file, proxy-pass, ... etc" .
  • More is coming, just stay tuned .

How It Works

  • A request hits the xerver .
  • xerver handles the request .
  • xserver send it to the backend fastcgi process and the main controller file .
  • the controller file contains your own logic .
  • fastcgi process reply to xerver with the result .
  • xerver parse the result and then prepare it to be sent to the client .

Installation

1- Download the right binary for your os fromhere .

2- Extract the downloaded file contents to any directory say ./xerver/ "current directory" .

3- Using your Terminal cd ./xerver/ .

4- run the following command to display the available options ./xerver --help .

Example (1)

Only acts as a static file server

./xerver --static-dir=/path/to/www/ --addr=0.0.0.0:80

Example (2)

Listen on address 0.0.0.0:80 and send the requests to ./controller.php

./xerver --fcgi-proto=unix --fcgi-addr=/path/to/php-fpm.socks --fcgi-controller=./controller.php --http-addr=:80

** OR Listen on address 0.0.0.0:80 & 0.0.0.0:443 ** and send the requests to ./controller.php

./xerver --fcgi-proto=unix --fcgi-addr=/path/to/php-fpm.socks --fcgi-controller=./controller.php --http-addr=:80 --https-addr=:443 --https-cert=./cert.pem --https-key=./key.pem

Open your ./controller.phpand :

<?php        // uncomment any of the following to test it .        // here you perform your own logic      // echo "<pre>" . print_r($_SERVER, 1);        // some xerver internal header for some operations      // 1)- tell xerver to serve a file/directory to the client .      // header("Xerver-Internal-FileServer: " . __DIR__ . "/style.css");        // 2)- tell xerver to serve from another server "act as reverse proxy" .      // header("Xerver-Internal-ProxyPass: http://localhost:8080/");        // 3)- tell xerver to hide its own tokens "A.K.A Server header"      // header("Xerver-Internal-ServerTokens: off");        // the above headers won't be sent to the client .

Open your browserand go to localhost or any localhost paths/subdomains .

Building from source

1- make sure you have Golang installed .

2- go get github.com/alash3al/xerver
3- go install github.com/alash3al/xerver

4- enjoy .

Author

By Mohammed Al Ashaal

 本文由用户 edison1221 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1456977901875.html
FastCGI 反向代理 Go语言 Google Go/Golang开发