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
    • 最新
    • 标签
主页 / user-332391

Cunning's questions

Martin Hope
Cunning
Asked: 2017-02-23 18:59:42 +0800 CST

Nginx+PHP-FPM:让php处理文件扩展名

  • 1

我正在尝试提供一个处理一些 RESTful URI 的 PHP 脚本并了解最终用户需要哪种格式的数据,我将其作为 URI 中的扩展名进行处理,例如:

example.com/foo/bar.json?q=x&a=y --> data in ajax format
example.org/foo/bar.xml?q=x&a=y  --> data in xml format

我在我的开发机器中使用了 Apache httpd + modphp,它工作得很好,但是舞台服务器使用了 CentOS + Nginx + PHP。在那里,nginx 拦截并尝试处理静态 json 文件并返回 404。

如何防止 Nginx 处理某些文件类型(例如 json、xml)并让 PHP 处理这些文件?

我的 Nginx 配置:

server {

  # listen [::]:443 ssl http2 accept_filter=dataready;  # for FreeBSD
  # listen 443 ssl http2 accept_filter=dataready;  # for FreeBSD
  # listen [::]:443 ssl http2 deferred;  # for Linux
  # listen 443 ssl http2 deferred;  # for Linux
  listen [::]:443 ssl http2;
  listen 443 ssl http2;

  # The host name to respond to
  server_name example.com;

  include h5bp/directive-only/ssl.conf;
  include ssl/conf/example.com;

  # Path for static files
  root /var/www/example.com/app/public;
  index index.php index.html index.htm;

  #Specify a charset
  charset utf-8;

  # Custom 404 page
  error_page 404 /404.html;

  # Include the basic h5bp config set
  include h5bp/basic.conf;

  # log settings
  access_log off;
  error_log  /var/log/www/example.com/nginx/error/error.log error;

  # turn off access logs and prevents logging
  # an error if robots.txt and favicon.ico are not found
  location = /favicon.ico { access_log off; log_not_found off; }
  location = /robots.txt  { access_log off; log_not_found off; }


  # check if a file or directory index file exists,
  # else pass the request to the index.php as a query parameter.
  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  # handle execution of PHP files
  # set php5-fpm socket
  # tell NGINX to proxy requests to PHP FPM via the FCGI protocol
  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass localhost:9003;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
  }

  # block access to .htaccess files
  location ~ /\.ht {
    deny all;
  }

}

更新:它终于工作了,我把 json 相关的位置放在主要/位置,并将$script_file_namejson 相关的位置更改为静态脚本名称。感谢蒂姆。

nginx static-content extension php-fpm
  • 1 个回答
  • 1910 Views
Martin Hope
Cunning
Asked: 2016-08-07 02:34:58 +0800 CST

NGINX:将请求副本发送到另一个上游

  • 5

我们的团队开发了一个分析应用程序,它记录和分析所有传入(未丢弃)的请求。在这种情况下,我必须在我的反向代理解决方案中将所有请求的副本发送到另一个上游。

单独使用NGINX可以吗?或者还有其他对当前反向代理结构影响最小的解决方案吗?

最好在 NGINX 中这样做,以便 NGINX 对请求的处理已经完成,并且请求将与发送到上游目的地的请求相同。

PS:分析应用不返回任何响应

nginx reverse-proxy
  • 1 个回答
  • 7046 Views
Martin Hope
Cunning
Asked: 2016-01-18 06:27:15 +0800 CST

从有效的通配符证书生成子域证书

  • 9

鉴于 SSL 证书和可以链接的密钥的性质,我(我自己)是否可以根据为通配符子域颁发的主域证书和密钥为子域生成证书?

这里的做法是,我必须为一个子域设置一个新的完全不同的远程(物理)服务器,并且我想尽量减少主证书和密钥被劫持的风险,以防万一。

我可以使用提供我的主域、通配符证书和密钥的 openssl 实用程序来执行此操作,还是应该再次由 CA 辞职?如果可以,怎么做?

谢谢

ssl
  • 1 个回答
  • 11534 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