官網:Beginner’s Guide
翻譯部分:Setting Up FastCGI Proxying
tips: FastCGI是一個協議
開始!
nginx can be used to route requests to FastCGI servers which run applications built with various frameworks and programming languages such as PHP.
nginx可以用來路由請求到用各種各樣的框架和編程語言建立的FastCGI服務器上,
The most basic nginx configuration to work with a FastCGI server includes using the fastcgi_pass directive instead of the
proxy_passdirective, and fastcgi_param directives to set parameters passed to a FastCGI server.
能夠和FastCGI服務器作業最基本的nginx配置包括fastcgi_pass,fastcgi_param指令,
fastcgi_param設定傳個FastCGI服務器的引數,
Suppose the FastCGI server is accessible on
localhost:9000.
假設在localhost:9000上可以訪問到FastCGI服務器,
Taking the proxy configuration from the previous section as a basis, replace the
proxy_passdirective with thefastcgi_passdirective and change the parameter tolocalhost:9000.
將之前那些部分的demo:proxy_pass http://localhost:8080/; 修改成下面這樣
fastcgi_pass localhost:9000;
In PHP, the
SCRIPT_FILENAMEparameter is used for determining the script name, and theQUERY_STRINGparameter is used to pass request parameters.
在PHP中,SCRIPT_FILENAME引數用來決定腳本名稱
QUERY_STRING引數用來傳遞請求引數
The resulting configuration would be:
server {
location / {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
}
location ~ \.(gif|jpg|png)$ {
root /data/images;
}
}
最終組態檔長這樣,
This will set up a server that will route all requests except for requests for static images to the proxied server operating on
localhost:9000through the FastCGI protocol.
上面的配置會設定一個服務器,它會通過FastCGI協議,路由除靜態檔案請求以外的請求到跑在localhost:9000 上的被代理服務器,
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/350863.html
標籤:其他
