AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[fastcgi](server)

Martin Hope
JeremyCanfield
Asked: 2021-11-22 02:38:23 +0800 CST

HAProxy 下载 PHP 文件而不是在浏览器中显示

  • 0

我在 Docker 上运行 nginx 和 php-fpm。当使用我的 Docker 系统的主机名 (docker1.freekb.net) 时,phpinfo.php 页面会显示在浏览器中,因此我知道我已经正确配置了 nginx 和 php-fpm 以提供 PHP 页面。这是 /etc/nginx/conf.d/default.conf 中的服务器块。来自 nginx 的 80 端口的请求被转发到 PHP 的 9000 端口。

server {
    listen              80;
    server_name         stage.freekb.net;
    root                /var/www/stage;
    index               index.html phpinfo.php;
    location / {
        try_files $uri $uri/ /index.html;
    }
    location ~ \.php$ {
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 0.0.0.0:9000;
        fastcgi_index phpinfo.php;
        include fastcgi_params;
    }
}

我有 HAProxy 设置以将请求转发到 nginx。这是我在 /etc/haproxy/haproxy.cfg 中的监听块。当我访问http://haproxy.freekb.net/index.html时,会显示 nginx 欢迎页面,因此我知道 HAProxy 能够将请求转发到 nginx。

但是,当我访问http://haproxy.freekb.net/phpinfo.php时,phpinfo.php 会下载到我的本地 PC。我怀疑这意味着 fastcgi 有问题。我不确定在使用 HAProxy 时要在浏览器中显示 PHP 页面需要进行哪些更改。

listen nginx
    bind *:80
    mode tcp
    balance roundrobin
    server nginx1 docker1.freekb.net:80 check
fastcgi nginx php-fpm haproxy
  • 1 个回答
  • 86 Views
Martin Hope
ArcanisGK507
Asked: 2021-10-02 21:13:42 +0800 CST

网页显示超时网关错误 FastCGI

  • 1

以我有限的知识,我继续解释这个问题和场景有点复杂。

最初我认为这是与我的脚本和查询的性能相关的一些问题,所以我在网站上用西班牙语创建了这篇文章:LINK

但是在研究了下午的大部分时间之后;我将把这一切都归因于我的开发环境的错误配置。

我正在使用 2 台设备服务器:

  1. 当地的:

    • 视窗 10
    • 拉拉贡服务器
  2. 发展:

    • Ubuntu 20.04
    • XAMPP

在这种情况下,我将专注于本地:
我已将 laragon 堆栈配置为支持虚拟主机并运行 2 个版本的 PHP(7.2 / 7.4)我遵循以下 2 个指南:链接 1和链接 2

我的阿帕奇配置:

Define SRVROOT "C:/laragon/bin/apache/httpd-2.4.47-win64-VS16"

ServerRoot "C:/laragon/bin/apache/httpd-2.4.47-win64-VS16"


Listen 80


LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule version_module modules/mod_version.so

<IfModule unixd_module>
    User daemon
    Group daemon
</IfModule>

ServerAdmin [email protected]

ServerName Laragon

<Directory />
    AllowOverride none
    Require all denied
</Directory>


DocumentRoot "C:/laragon/www"
<Directory "C:/laragon/www">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error.log"

LogLevel error

<IfModule log_config_module>
    
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access.log" common

</IfModule>

<IfModule alias_module>
    
    ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock cgisock
</IfModule>


<Directory "${SRVROOT}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>

    TypesConfig conf/mime.types


    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

</IfModule>



# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
    Include conf/extra/proxy-html.conf
</IfModule>


<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

AcceptFilter http none
AcceptFilter https none
EnableSendfile Off
EnableMMAP Off

IncludeOptional "C:/laragon/etc/apache2/alias/*.conf"
IncludeOptional "C:/laragon/etc/apache2/sites-enabled/*.conf"
Include "C:/laragon/etc/apache2/httpd-ssl.conf"
Include "C:/laragon/etc/apache2/mod_php.conf"

ScriptAlias /php72 "C:/laragon/bin/php/php72"
Action application/x-httpd-php72-cgi /php72/php-cgi.exe
<Directory "C:/laragon/bin/php/php72">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>

虚拟主机:

<VirtualHost *:80> 
    DocumentRoot "D:/webdev/Local/test1/"
    ServerName test1.me
    ServerAlias *.test1.me
    <Directory "D:/webdev/test1/">
        AllowOverride All
        Require all granted
    </Directory>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php72-cgi
    </FilesMatch>
</VirtualHost>

phpmyadmin 的别名

Alias /phpmyadmin "C:/laragon/etc/apps/phpMyAdmin/"
<Directory "C:/laragon/etc/apps/phpMyAdmin/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all  
    Require local
</Directory>

MySQL 配置

[client]
#password=your_password
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
key_buffer_size=512M
max_allowed_packet=4096M
table_open_cache=256
sort_buffer_size=32M
read_buffer_size=32M
read_rnd_buffer_size=32M
myisam_sort_buffer_size=128M
thread_cache_size=16

secure-file-priv=""
explicit_defaults_for_timestamp=1
datadir= "C:/laragon/data/mysql"
lower_case_table_names=2
sql_mode=""
wait_timeout=28800
interactive_timeout=28800


[mysqldump]
quick
max_allowed_packet=4096M

两个版本的 PHP 配置 (7.2/7.4)

file_uploads = On
upload_max_filesize = 4096M
max_file_uploads = 100
allow_url_fopen = On
memory_limit = 3G
post_max_size = 600M
max_execution_time = 5000
max_input_time = 5000
max_input_vars = 5000
date.timezone= America/Panama
error_reporting = E_ALL
display_errors = on
display_startup_errors = on
html_errors = On
session.gc_maxlifetime = 2592000
session.cache_expire = 2592000

如您所见,我默认使用 apache 处理程序 2.0 为 php 7.4 提供服务;我正在使用别名服务 php 7.2。

  • phpmyadmin => php 7.4 Apache 处理程序 2.0
  • test1.me => php 7.2 CGI/FastCGI

MySQL的错误日志:

2021-10-02T04:26:59.472441Z 35 [Note] Aborted connection 35 to db: avipac_dbproducts' user: 'root' host: 'localhost' (Got an error writing communication packets)

Apache的错误日志:

[Fri Oct 01 23:22:17.806390 2021] [cgi:error] [pid 3808:tid 1108] [client 127.0.0.1:61857] Script timed out before returning headers: php-cgi.exe, referer: http://test1.me/
[Fri Oct 01 23:23:43.661155 2021] [cgi:error] [pid 3808:tid 1108] [client 127.0.0.1:61857] AH01215: PHP Fatal error:  Allowed memory size of 3221225472 bytes exhausted (tried to allocate 20480 bytes) in D:\\webdev\\Local\\test1\\control\\classgeneric\\class.managerdb.php on line 111: C:/laragon/bin/php/php72/php-cgi.exe, referer: http://test1.me/
[Fri Oct 01 23:23:43.676759 2021] [cgi:error] [pid 3808:tid 1108] [client 127.0.0.1:61857] AH01215: PHP Fatal error:  Allowed memory size of 3221225472 bytes exhausted (tried to allocate 65536 bytes) in Unknown on line 0: C:/laragon/bin/php/php72/php-cgi.exe, referer: http://test1.me/
[Fri Oct 01 23:23:43.676759 2021] [cgi:error] [pid 3808:tid 1108] [client 127.0.0.1:61857] AH01215: PHP Fatal error:  Allowed memory size of 3221225472 bytes exhausted (tried to allocate 24576 bytes) in Unknown on line 0: C:/laragon/bin/php/php72/php-cgi.exe, referer: http://test1.me/
[Fri Oct 01 23:24:59.451291 2021] [cgi:error] [pid 3808:tid 1104] [client 127.0.0.1:53918] Script timed out before returning headers: php-cgi.exe, referer: http://test1.me/

我绝对接受 mysql 查询对于 Windows 上的本地环境来说是比较大的;但问题是 apache 处理程序 2.0 和 php 7.4 在不到 1 秒的时间内执行了相同的查询......但在 CGI / FastCGI 中,它在达到超时(180 秒 / 3 分钟)时停止......我有为 FastCGI 和 Apache Handler 2.0 设置相同的设置,但并不令人信服,因为一个失败而另一个没有。

当然,这就是为什么我的疑惑之一是他们在我的设置中告诉我我需要什么配置来改进 FastCGI。这是我主要忽略的。(在哪里,如何和什么)。

可能有人在我的设置中告诉我需要什么配置来改进 FastCGI。这是我主要忽略的。(在哪里,如何和什么)我真的不明白为什么我不能让 Fast CGI 至少不能像 Apache 那样破坏和工作......

我不知道出了什么问题,我需要什么或如何解决这些错误......我知道 CGI / FastCGI 需要很长时间并消耗大量内存,但我不知道为什么它不起作用和 Apache Handler正常工作

或者是否存在代理 Apache Handler 2.0 的任何方式,而不是通过 FastCGI 别名使用 php-cgi?


说明性图像 Apache Handler 2.0:

在此处输入图像描述

CGI/FastCGI:

在此处输入图像描述

在此处输入图像描述


更新#1

我找到了这个配置文件: 注意:我假设这个配置文件很重要;但我不知道它的功能或者我应该添加、删除或修改什么东西以使 FastCGI 表现得像 Apache Handler 2.0。

    LoadModule fcgid_module "C:/laragon/etc/apache2/modules/mod_fcgid-2.3.10-win64-VS16.so"

<IfModule fcgid_module>
    FcgidInitialEnv PATH "C:/laragon/bin/php/php74;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;"
    FcgidInitialEnv SystemRoot "C:/Windows"
    FcgidInitialEnv SystemDrive "C:"
    FcgidInitialEnv TEMP "C:/Windows/Temp"
    FcgidInitialEnv TMP "C:/Windows/Temp"
    FcgidInitialEnv windir "C:/Windows"

    # 10 hrs: in case you have long running scripts, increase FcgidIOTimeout 
    
    FcgidIOTimeout 36000
    FcgidIdleTimeout 36000
    FcgidProcessLifeTime 36000
    FcgidBusyTimeout 36000
    FcgidConnectTimeout 3600
    FcgidMaxRequestsPerProcess 0
    FcgidMaxProcesses 50
    FcgidMaxRequestLen 81310720
    # Location php.ini:
    # FcgidInitialEnv PHPRC "C:/laragon/bin/php/php74"
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 0

    <Files ~ "\.php$>"
        AddHandler fcgid-script .php
        Options +ExecCGI
        FcgidWrapper "C:/laragon/bin/php/php74/php-cgi.exe" .php
    </Files>
</IfModule>
mysql fastcgi apache-2.4 php-fastcgi
  • 1 个回答
  • 359 Views
Martin Hope
knofun
Asked: 2021-05-01 08:31:16 +0800 CST

NGINX:忽略用于 FastCGI 缓存目的的 fbclid 参数

  • 0

这里有对这个问题的一些很好的回答:NGINX: Ignoring certain URL Parameters for Cache Purposes

但我似乎无法让它发挥作用。我正在运行 wordpress 安装,这是我的映射:

map $args $cachestep1 {
  default $args;
  ~^(fbclid=[^&]*&?)(.*)$             $2;
  ~^([^&]*)(&fbclid=[^&]*)(&?.*)$     $1$3;
}

还有我的缓存键:

fastcgi_cache_key $scheme$host$request_method$uri$cachestep1;

我仍然在具有不同 fbclids 的完全相同的 url 上获得缓存 MISS。

cache fastcgi nginx wordpress
  • 1 个回答
  • 203 Views
Martin Hope
Timothy R. Butler
Asked: 2021-04-12 07:00:46 +0800 CST

2021 年 FastCGI 还好吗?

  • 0

似乎这里关于 FastCGI 的大多数讨论都在近十年前被冻结了,所以作为一个刚刚决定开始使用它的人,我想知道我是否在面对不可预见的安全性或兼容性问题时犯了错误。以下是一些引起我关注的事情:

  • 看起来像 Perl CPAN 模块这样的库已经好几年没有更新了。
  • Perl 模块在UTF-8 输出变得正常多年后抱怨说,缺乏更新似乎并没有为修复提供很大的希望。
  • 我还注意到,Mojolicious 几年前剥离了对 FastCGI 的支持,因为它不符合代码库的质量标准。我目前不使用 Mojolicious,但我发现这很值得注意。

今年终于觉醒到 FastCGI 是不是已经选择了死胡同?

我有使用 PHP 的客户,所以我对 PHP 支持很感兴趣,但我主要感兴趣的是是否有更好的面向未来的替代方案来支持 Perl,这是我用于大多数 CGI 程序的语言在服务器上。也许我想多了,FastCGI 就可以了。到目前为止,我使用mod_fcgid的是 Apache,尽管我的目标是让它直接与 Nginx 一起运行,我已经在使用它来提供静态内容。

perl fastcgi nginx mod-fcgid
  • 1 个回答
  • 336 Views
Martin Hope
Грузчик
Asked: 2021-04-06 10:03:40 +0800 CST

如何使用 curl 和 telnet 而不是 cgi-fcgi?

  • 0

我正在使用这个 script.c:

#include <fcgi_stdio.h>
#include <stdlib.h>
int main (void) {
while (FCGI_Accept() >= 0) {
    printf("Status: 200 OK\r\n");
    printf("Content-type: text/html\r\n\r\n");
    printf("<!doctype><html><body>Welcome!</body></html>\n");
}
return EXIT_SUCCESS;
}

我编译它使用

gcc script.c -o script.fcgi -lfcgi -O3 -Wall -Wextra -pedantic -std=c11

然后,我输入终端:

 cgi-fcgi -start -connect localhost:9000 script.fcgi
 cgi-fcgi -connect localhost:9000 script.fcgi

并获得输出

Status: 200 OK
Content-type: text/html

<!doctype><html><body>Welcome!</body></html>

之后,我使用了 curl

 curl localhost:9000
 curl: (52) Empty reply from server

和远程登录

 telnet localhost 9000
 Connected to localhost.
 GET / HTTP/1.1
 Connection closed by foreign host.

为什么我只使用 cgi-fcgi 获得成功结果?如何使用 curl 和 telnet 从脚本中获取相同的数据?

fastcgi telnet curl linux-networking
  • 1 个回答
  • 1142 Views
Martin Hope
CaptainCodeman
Asked: 2020-10-19 06:22:44 +0800 CST

是否可以将 nginx 配置为仅处理 SSL?

  • 2

我已经有一个用 C++ 编写的 Web 服务器,但它使用没有 SSL 的 TCP 套接字。我想将它连接到网络上,但我想使用 nginx 之类的东西来处理 SSL,以及 DDOS 保护、smurf 攻击保护等基本安全性。

我的问题是,我可以设置 nginx 来处理安全 SSL 连接,并将未加密的 http 流量转发到我的 Web 服务器(在同一台机器上)吗?

我觉得这可能是一个更简单的替代方法,可以将我的应用程序设置为通过 FastCGI 与 nginx 交互。

(任何其他建议,请随时提出)

ssl fastcgi nginx
  • 1 个回答
  • 131 Views
Martin Hope
Malanie
Asked: 2020-06-23 19:02:18 +0800 CST

Nginx 位置指令 - 文件被下载

  • 0

我目前已经设置了一个与 uri 匹配的 Nginx 位置块,当且仅当它以/auth/test.php. 唯一的匹配是http://host/auth/test.php.

location  ~ ^/auth/test\.php$ {

        # Use try files or the if statement below. try_files is preferred
        # If the original URI ($uri) does not resolve into an existing file or directory, a 404 error is returned
        try_files $uri =404;

        fastcgi_split_path_info ^(.+\.php)(/.+)$; #

        fastcgi_param USERNAME $arg_username;
        fastcgi_param PASSWORD $arg_password;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        include fastcgi_params;
}

我的理解是,当 Nginx 尝试匹配位置块时,查询参数不起作用。test.php当 uri 的形式为 时,会处理我的脚本http://host/auth/test.php?username=blah&password=blah。但是,如果我尝试不带查询参数 () 的 uri,http://host/auth/test.php则脚本test.php会被请求它的人下载,这并不理想。有没有办法让 Nginx 不处理这种类型的 uri 请求?我认为该try_files指令会处理这种情况,但显然不是。谢谢。

fastcgi nginx php-fpm
  • 2 个回答
  • 218 Views
Martin Hope
mahatmanich
Asked: 2017-01-08 15:27:45 +0800 CST

在 debian 8 上使用 nginx 设置 xymon 在 cgi 脚本上给出 403

  • 0

我正在尝试在 debian 上使用 nginx 设置 xymon,并且我已经完成了初始设置。

但是,每当我点击 cgi 脚本时,我都会收到 403 错误。

这是我的设置:

server {
        listen 127.0.0.1:8081;

        server_name localhost;
        index       index.html;
        root        /var/lib/xymon/www;

        error_log /var/log/nginx/xymon.error.log;
        access_log /var/log/nginx/xymon.access.log;

        location /xymon/ {
                alias /var/lib/xymon/www/;
        }

        location /cgi-bin/ {
                alias /usr/lib/xymon/cgi-bin/;
        }

        location /cgi-secure/ {
                alias  /usr/lib/xymon/cgi-secure/;
        }

       location ~ ^/.*\.sh$ {
                gzip off;
                fastcgi_param SCRIPT_NAME $fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT /var/lib/xymon/;
                fastcgi_param REMOTE_USER $remote_user;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
       }
}

我试图从这个 freeBSD 设置中对其进行调整: https ://blog.feld.me/posts/2014/11/setting-up-xymon-with-nginx/

我得到一些无用的日志:127.0.0.1 - - [08/Jan/2017:00:25:14 +0100] "GET /cgi-bin/findhost.sh HTTP/1.1" 403 25

有没有人用 nginx 在 debian 上设置 xymon 并让它工作?

fastcgi nginx debian-jessie xymon
  • 1 个回答
  • 684 Views
Martin Hope
Iskar
Asked: 2016-12-06 02:01:34 +0800 CST

nginx“fastcgi_cache_valid 404”不工作

  • 1

我正在用 nginx 做简单的缓存。它适用于 200 个响应,但 404 个响应由于某种原因没有“命中”缓存逻辑,我不明白为什么。

我所说的“没有命中缓存逻辑”是基于我的add_header X-Cached. 如果是 404 响应,则根本不会出现此标头。

404 响应:

< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Mon, 05 Dec 2016 09:54:34 GMT
< Content-Type: application/json
< Content-Length: 55
< Connection: keep-alive
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache

200 回复:

< HTTP/1.1 200 OK
< Server: nginx
< Date: Mon, 05 Dec 2016 09:54:56 GMT
< Content-Type: application/json
< Content-Length: 1186
< Connection: keep-alive
< Set-Cookie: PHPSESSID=5hq364dphuo8ka26sbcadiak74; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< X-Cached: MISS

相关的nginx配置:

location / {
    try_files $uri /index.php$is_args$args;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    fastcgi_cache_key $request_uri?$is_args$args;
    fastcgi_cache CACHENAME;
    fastcgi_cache_valid 200 90d;
    fastcgi_cache_valid 404 365d;
    fastcgi_cache_use_stale updating error timeout invalid_header http_404 http_500;

    fastcgi_cache_methods GET HEAD;
    fastcgi_ignore_headers Cache-Control Set-Cookie Expires X-Accel-Expires Vary;

    add_header X-Cached $upstream_cache_status;
}

我的应用程序是一个 REST API,所以 404 的响应只是说路由返回了错误的响应。我希望缓存此响应。

我究竟做错了什么?感谢您的任何想法!

cache fastcgi nginx php-fpm
  • 1 个回答
  • 765 Views
Martin Hope
Troels Johannesen
Asked: 2016-10-31 13:17:08 +0800 CST

Nginx / FastCGI - 在子目录中调用 PHP 文件

  • 0

我们在调用域子目录中的 php 文件时遇到问题。

什么工作没有问题:

example.com/mod/eco/file.php

但是当我们的域被放置在一个虚拟子目录中时,它不会像这样工作:

example.com/b2b-dk/mod/eco/file.php

这是 nginx 配置文件:

server {
    listen 80;
    listen [::]:80;
    server_name .example.com;
    root /home/forge/example.com;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
      index /index.php;

      rewrite ^/admin462twqbah/?$ /admin462twqbah/index.php permanent;
      rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
      rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last;
      rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
      rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
      rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
      rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
      rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
      rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
      rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
      rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
      rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last;
      rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
      try_files $uri $uri/ /index.php?$args;
    }

    location /b2b-dk/ {
      rewrite ^/b2b-dk/(.*)$ /$1 last;
      try_files $uri $uri/ /index.php?$args;
    }

    location /b2b-eu/ {
      rewrite ^/b2b-eu/(.*)$ /$1 last;
      try_files $uri $uri/ /index.php?$args;
    }

    location /b2b-us/ {
      rewrite ^/b2b-us/(.*)$ /$1 last;
      try_files $uri $uri/ /index.php?$args;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/example.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /b2b-dk/.+\.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

所以我试图让这部分工作:

location ~ /b2b-dk/.+\.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
            include fastcgi_params;
        }

但没有任何运气 - 我做错了什么?

fastcgi nginx php-fpm
  • 1 个回答
  • 207 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve