我这里有一个奇怪的问题。我刚刚从 apache + mod_php 转移到 nginx + php-fpm。除了这个问题,一切都很好。
我有一个网站,比如说example.com。当我像example.com?test=get_param $_SERVER['REQUEST_URI']is一样访问它时/?test=get_param,还有一个$_GET['test']。
但是,当我访问example.com/ajax/search/?search=get_param $_SERVER['REQUEST_URI']时/ajax/search/?search=get_param仍然没有$_GET['search'](有没有$_GET在所有的阵列)。
我正在使用 Kohana 框架。哪个路由/ajax/search到控制器,但我已经把它phpinfo()放在index.php所以我$_GET在框架做任何事情之前检查变量(这意味着消失的获取参数不是框架的错误)。
我的nginx.conf是这样的
worker_processes 4;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
index index.html index.php;
autoindex on;
autoindex_exact_size off;
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
error_log …Run Code Online (Sandbox Code Playgroud) 我有一个相对简单的配置:
upstream appserver-1 {
server unix:/var/www/example.com/app/tmp/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://appserver-1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
auth_basic "Restricted";
auth_basic_user_file /path/to/htpasswd;
}
location /api/ {
auth_basic off;
}
}
Run Code Online (Sandbox Code Playgroud)
目标是在整个网站上使用基本身份验证,除了在/api/子树上。虽然它确实适用于基本身份验证,但其他指令proxy_pass也不起作用/api/。
是否可以仅禁用基本身份验证,同时保留其他指令而不复制和粘贴所有内容?
如何在文件路径中使用变量名?
ssl_certificate /home/ec2-user/.certificados/$server_name.crt;
ssl_certificate_key /home/ec2-user/.certificados/$server_name.key;
Run Code Online (Sandbox Code Playgroud) 假设我有这个 nginx 配置文件
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=myCache:8m max_size=100m inactive=1h;
Run Code Online (Sandbox Code Playgroud)
keys_zone=myCache:8m意思?文档中没有太多说明:此外,所有活动密钥和有关数据的信息都存储在共享内存区域中,其名称和大小由 keys_zone 参数配置。
如果proxy_cache_valid( 12h) 高于 中的指定inactive值 ( 1h)proxy_cache_path怎么办?它将遵循哪个规则?例如
proxy_cache_valid 200 302 12h;
proxy_cache_valid 404 302 1h;
Run Code Online (Sandbox Code Playgroud)谢谢!
例如,哪个位置块可能匹配 HTTPGET请求
GET /git/sample-repository/info/refs?service=git-receive-pack HTTP/1.1
Run Code Online (Sandbox Code Playgroud) 我知道HttpRewriteModule,但我真的不知道如何处理正则表达式,我需要将某个目录中的所有 URL 重定向到另一个目录,特别是
example.com/component/tag/whatever
Run Code Online (Sandbox Code Playgroud)
到
example.com/tag/whatever
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何在 Nginx 中做到这一点吗?
我在这里遇到了一些使用这种语法的问题和答案:
location @default {
# ...
}
location /somewhere {
try_files $uri @default;
}
Run Code Online (Sandbox Code Playgroud)
我在谷歌上进行了高低搜索,但似乎找不到任何相关文档。它是什么意思,它的一些实际用途是什么?它是某种变量声明和赋值吗?对不起,新手问题。
我在我的 conf 文件中有以下设置
upload_set_form_field $upload_field_name.name "$upload_file_name";
Run Code Online (Sandbox Code Playgroud)
但我想将选择的参数名称更改为:
upload_set_form_field ($upload_field_name+"[name]") "$upload_file_name";
Run Code Online (Sandbox Code Playgroud)
所以我可以得到“附件[名称]”,但这不起作用。如果有人可以帮助我将变量与 nginx 配置文件中的字符串合并,我会很高兴:)。
调试 6 小时后 - 我放弃了:|
我们在 LAN 中有一个 nginx+php-fpm+mysql,有近 100 个 wordpress(由不同的设计人员/开发人员创建和使用,他们都在测试 wordpres 设置)
我们长期使用 nginx 没有任何问题。
今天,突然间——nginx开始突然返回“504网关超时”......
我检查了虚拟主机的 nginx 错误日志...
2010/09/06 21:24:24 [error] 12909#0: *349 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:11 [error] 12909#0: *349 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: …Run Code Online (Sandbox Code Playgroud) 我正在我的 Fedora 服务器上安装一个 nginx ssl 代理。
我在 /etc/nginx.conf 下创建了一个证书和密钥对。它们看起来像这样:
ls -l /etc/nginx/
total 84
...
-rw-r--r--. 1 root root 1346 Sep 20 12:11 demo.crt
-rw-r--r--. 1 root root 1679 Sep 20 12:11 demo.key
...
Run Code Online (Sandbox Code Playgroud)
作为 root,我正在尝试启动 nginx 服务:
systemctl start nginx.service
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
nginx[30854]: nginx: [emerg]
SSL_CTX_use_certificate_chain_file("/etc/nginx/demo.crt") failed (SSL: error:0200100D:system library:fopen:Permission denied...e:system lib)
nginx[30854]: nginx: configuration file /etc/nginx/nginx.conf test failed
Run Code Online (Sandbox Code Playgroud)
这些文件的权限有问题吗?