我不能嵌套,如果我没有和运营商使用的话,那么我将如何取消嵌套: if ($AUTHENTICATED) { proxy_pass http://backend; { if (!$AUTHENTICATED) { if ($args ~ out=xml) { rewrite (.*)$ $1.xml break; } if ($args ~ out=csv) { rewrite (.*)$ $1.csv break; } }
我有一个nodejs运行在端口8000和nginx端口80在同一台服务器上。 我希望Nginx能够处理所有的请求(image,css等),并将js请求转发到端口8000上的nodejs服务器。 有没有可能做到这一点。 我已经将nginxconfiguration为反向代理,但是它将每个请求转发给nodejs,但是我希望nginx处理除js以外的所有请求。 nginx的/启用的站点- /默认/ upstream nodejs { server localhost:8000; #nodejs } location / { proxy_pass http://192.168.2.21:8000; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering 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; } 更新尝试这个:但没有任何改变,仍然nginx转发每个请求到nodejs server { listen 192.168.2.21:80; server_name server; access_log /var/log/server/access.log; error_log /var/log/server/error.log; root /var/www/static; location / […]
我的nginx.conf: location ~ ^/api/(.*)$ { alias /home/username/apidav/$remote_user/$1; client_body_temp_path /var/www/path/; client_max_body_size 50m; dav_methods PUT DELETE MKCOL;# COPY MOVE; create_full_put_path on; dav_access user:rw group:rw all:r; dav_ext_methods PROPFIND OPTIONS; auth_request /api_auth; } location /api_auth { internal; proxy_pass http://www.domain.ru/accounts/api_auth/; proxy_pass_request_body off; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; } curl -T test.txt'http :// gert:[email protected]/api/'curl :(56)Recv失败:连接重置由peer? 为什么? tail -f /var/log/nginx/error.log 2012/11/16 […]
我在EC2(m1.small)上运行一个nginx进行SSL终止。 我在Ubuntu上使用了两名工作者,最新的nginx(稳定版),networking吞吐量约为2Mbps ,系统平均负载约为2-3。 我想知道现在这个系统是否健康, 例如 什么是队列长度(我知道nginx可以处理大量的并发请求,但我的意思是在请求被服务之前,他们有多less人需要等待之前被服务) 给定请求的平均排队时间是多less? 我想知道,因为如果我的nginx是CPU有限 (例如由于SSL),我将需要升级到更快的实例。 我目前的nginx状态 Active connections: 4076 server accepts handled requests 90664283 90664283 104117012 Reading: 525 Writing: 81 Waiting: 3470
我在一个centos 6.3 virtualbox 4.2.4虚拟机里面使用了nginx 1.3.8。 系统通过yum更新运行最新的软件。 主机操作系统是windows 7.站点文件nginx正在服务于挂载的samba分区,这是主机Windows系统上的一个文件夹。 也就是说,在linux内部,nginxpath指的是/ home / vhosts,它是从Windows的D:\ vhosts \挂载的。 samba分区以root身份挂载,拥有777个特权。 / etc / fstab看起来像这样,但真正的ip,用户名,密码: //hostip/vhosts /home/vhosts cifs username=username,password=SECRETPASSWORD,uid=root,gid=root,file_mode=0777,dir_mode=0777,rw,_netdev 0 0 也就是说linux / nginx从windows共享里读取,而不是相反。 在/etc/samba/smb.conf中,我尝试禁用所有的sambalockingfunction,但是即使在重新启动虚拟机之后,它似乎也没有任何作用。 locking=no share modes=no oplocks = no level2 oplocks = no kernel oplocks =no 在Windows或Linux中,当我尝试覆盖已被nginx至less访问过一次的窗口中的javascript文件时,我收到“Access is denied”错误。 如果我运行“服务nginx重新加载”,锁被删除,我可以保存该文件。 这就是为什么我认为这是nginx导致locking。 目录也会出现同样的问题。 但是,这可能是与使用桑巴无关的另一个问题。 我正在使用samba,以便可以pipe理虚拟机之外的源代码。 另外请注意,运行“service nginx reload”之后,我正在编辑的文件实际上会自动从Windows主机中删除。 解决:我刚刚检查了我的nginx.conf文件。 看来“open_file_cache”function是什么导致locking和删除的文件。 […]
我想避免重复nginx中的所有虚拟主机服务器块,只是为了让自定义ssl设置与普通的http请求略有不同。 大多数SSL指令可以放在主块,除了一个障碍,我找不到一个解决方法:不同的保持活着的https和http 有什么办法可以使用$scheme来dynamic改变keepalive_timeout吗? 我甚至认为我可以使用more_set_input_headers -r 'Keep-Alive: timeout=60'; 有条件地取代保活超时只有当它已经存在,但问题是$scheme不能在location即使用。 这是无效的location ^https {}
我真的需要帮助。 现在坐了一会儿,不知道该怎么办。 我想要实现一个非常简单的任务 – 重写一个不存在的PHP文件到另一个前所未有的PHP文件,所有参数如: this http://example.com/nonexistent.php?url=google.com to -> http://example.com/existent.php?url=google.com 我尝试了这样的事情: rewrite ^/nonexistent.php /existent.php; 哪个不工作(文件未find)。 但redirect一个不存在的HTML文件到这样的PHP文件: rewrite ^/nonexistent.html /existent.php; 作品。 我不想重写一个html文件,但这仍然是一个令人困惑的行为。 因此,它也尝试了这样的(和一些变化): rewrite ^/nonexistent.php?url=^(.*)$ /existent.php?url=$1; 这也是行不通的。 (也许语法不好) 任何帮助吗? 这将是非常好的!
在我的nginxconfiguration中,我有多个位置块,例如 location ~* /a { ..} location ~* /b { ..} location ~* /c { ..} 我想将expires头部应用于上述所有块,例如 location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ { expires 1y; } 由于在nginx , 位置块是相互独立的 ,所以不是在上面的每个位置重复[1] expires块,有没有更好的方式来写configuration? [1] location ~* /a { location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ … } location ~* /b { location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ … } location ~* /c { location ~* ^/.*\.(?:css|js|jpg|jpeg|gif|png)$ […]
比方说,我有一个名为xyz.co的网站,我也有其他的域名,如xyz.com, xyz.it, xyz.co.it 现在nginx可以正常工作,在port 80 nginx.conf中的server_name xyz.co我想所有其他域redirect到xyz.co我也想要www.*以上版本redirect到xyz.co 我怎样才能得到这个? 这是nginxnetworking服务器级别的变化? 或者我需要在DNS进行此更改?
我正在试图为以下情况实现nginx重写规则 请求: http://192.168.64.76/Shep.ElicenseWeb/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635 应该redirect到: http://localhost:82/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635 我试过这个没有运气: location /Shep.ElicenseWeb/ { rewrite ^/Shep.ElicenseWeb/ /$1 last; proxy_pass http://localhost:82; } 什么是正确的方式来执行这样的重写nginx?