Bur*_*ürk 15
安装另一个在不同端口上运行的Web服务器(Apache,Lighttpd).然后使用nginx将您的CGI请求代理到网络服务器.
在8080上安装了Web服务器之后,您只需要将其添加到nginx配置中
location /cgi-bin {
proxy_pass http://127.0.0.1:8080;
}
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请查看Nginx Location Directive Explained.
Dav*_*ell 14
Nginx没有本机CGI支持(它支持fastCGI).典型的解决方案是将Perl脚本作为fastCGI进程运行,并编辑nginx配置文件以将请求重定向到fastCGI进程.如果您只想运行CGI脚本,这是一个非常复杂的解决方案.
你必须使用nginx这个解决方案吗?如果您只想执行一些Perl CGI脚本,请考虑使用Apache或Lighttpd,因为它们带有CGI模块,这些模块将本地处理您的CGI脚本,并且不要求脚本作为单独的进程运行.为此,您需要安装Web服务器并编辑Web服务器配置文件以加载CGI模块.对于Lighttpd,您需要在配置文件中添加一行以启用CGI文件的处理.然后将CGI文件放入cgi-bin文件夹.
VBa*_*art 14
Nginx是一个Web服务器.您需要为任务使用应用程序服务器,例如uWSGI.它可以使用其原生的非常有效的二进制接口uwsgi与nginx交谈.
小智 6
我发现了这个:https: //github.com/ruudud/cgi 它说:
===
On Ubuntu: apt-get install nginx fcgiwrap
On Arch: pacman -S nginx fcgiwrap
Example Nginx config (Ubuntu: /etc/nginx/sites-enabled/default):
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
location / {
root /srv/static;
autoindex on;
index index.html index.htm;
}
location ~ ^/cgi {
root /srv/my_cgi_app;
rewrite ^/cgi/(.*) /$1 break;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /srv/my_cgi_app$fastcgi_script_name;
}
}
Run Code Online (Sandbox Code Playgroud)
将 root 和 fastcgi_param 行更改为包含 CGI 脚本的目录,例如此存储库中的 cgi-bin/ dir。
如果您是一个控制狂并手动运行 fcgiwrap,请务必相应地更改 fastcgi_pass。使用开箱即用的 fcgiwrap 设置时,示例中列出的路径是 Ubuntu 中的默认路径。
===
我正准备尝试一下。