我有一个网站,我需要改变的url结构。 旧url看起来像/olddir/part1_de.htm ,新url看起来像/newdir/sub/category/anotherpage.htm 。 有很多我需要做的URL重写,最后我假设大概有500个不同的重写。 由于我的网站stream量很大,我主要关心的是目前的性能。 我的问题是: 我假设对于每个请求,重写块将被parsing,正则expression式将被评估。 我对吗? 如果我使用这些重写,会有性能损失吗? nginx能处理这个吗? 进行大量重写时,是否有任何“最佳实践”?
有一个更好的方法吗? 我无法find一种方法来嵌套或应用boolean操作符到nginx中的条件。 基本上,如果有一个cookie集(非匿名用户),我们要打服务器。 如果cookie没有设置并且文件存在,我们想要服务器文件,否则命中服务器。 set $test "D"; if ($http_cookie ~* "session" ) { set $test "${test}C"; } if (-f $request_filename/index.html$is_args$args) { set $test "${test}F"; } if ($test = DF){ rewrite (.*)/ $1/index.html$is_args$args? break; } if ($test = DCF){ proxy_pass http://django; break; } if ($test = DC){ proxy_pass http://django; break; } if ($test = D){ proxy_pass […]
我使用nginx 1.2.6运行Ubuntu Desktop 12.04。 PHP是PHP-FPM 5.4.9。 这是我的nginx.conf的相关部分: http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { server_name testapp.com; root /www/app/www/; index index.php index.html index.htm; location ~ \.php$ { fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } server { listen 80 default_server; root /www index index.html index.php; location […]
我已经将我的网站分成不同的configuration文件,以保持更有条理。 这也使我能够取出单独的configuration文件,并使网站不可用。 我的每个站点的configuration文件如下所示: server { listen 80; server_name site1.domain.co.uk; root /var/www/php/site1; location / { index index.html index.php; try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri /index.php; fastcgi_pass php; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location /common { alias /var/www/common; } } 我的问题是,我必须重复每个网站的位置块吗? 或者我可以添加一个新的服务器块,将匹配的一切? 如果这是可能的,它会冲突我的configuration文件,匹配所有未映射到网站的域? 这个configuration文件如下所示: server { listen 80 […]
我试图运行一个“nginx -c /etc/nginx/nginx.conf”但我得到: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address […]
我在ubuntu 12.04 LTS(x64)上用nginx + php-fpm(5.4.11)设置服务器, 我从存储库安装了nginx,并自己编译了PHP。 当我启动php-fpm和nginx时,所有东西都可以正常工作 sudo /etc/init.d/php-5.4.11-fpm start sudo service nginx start 我可以在网页上显示一个phpinfo,到目前为止还不错。 pid在/etc/php-5.4.11/php-fpm.conf中是这样设置的 pid = /var/run/php-5.4.11/php-fpm.pid 和/ etc / nginx / sites-available / default location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-5.4.11/php-fpm.sock; fastcgi_index index.php; include fastcgi_params; } 现在,我想在服务器重新启动时启动PHP,所以我做了: update-rc.d php-5.4.11-fpm defaults 但是,当我重新启动服务器,我得到这个日志文件中的错误: ERROR: unable to bind listening socket for address '/var/run/php-5.4.11/php-fpm.sock': No […]
我试图设置nginx作为一个反向rpoxy服务器在前面closures使用基本身份validation进行身份validation的几个IIS Web服务器。 (注意 – 这与使用密码文件提供auth的nginx不一样 – 它只是在浏览器/服务器之间进行mathhelling everythnig) 它的工作types – 但反复提示一个页面上的每一个资源(图像/ CSS等)auth。 upstream my_iis_server { server 192.168.1.10; } server { listen 1.1.1.1:80; server_name www.example.com; ## send request back to my iis server ## location / { proxy_pass http://my_iis_server; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_http_version 1.1; proxy_pass_header Authorization; proxy_redirect off; proxy_buffering off; proxy_set_header […]
我有一个简单的nginx设置,事情工作正常。 我已经把索引设置如下: index index.html index.php server_name设置为local.nginx。 如果我请求http://local.nginx它工作正常,但如果我请求http://local.nginx/index.php – 原始文件发送到浏览器。 哪里不对? 请参阅下面的configuration: server { listen 80; server_name local.nginx; root /var/www/local.nginx/; index index.html index.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 编辑 我发现这只是发生在铬。 清除浏览器caching后,问题消失。 任何人都可以解释发生了什么?
每当我在mydomain.com上收到请求时,都会使用以下重写规则将其redirect到www子域: server_name mydomain.com; rewrite ^(.*)$ $scheme://www.mydomain.com$1 permanent; 但是,如果收到POST请求,它将被redirect为GET。 为什么? 什么是正确的方式来redirect呢?
我试图添加一个子域到我的nginx服务器,似乎无法得到它的工作。 这里是我的主服务器的configuration文件: server { listen 80; server_name www.kevin-whitaker.net; rewrite ^/(.*) http://kevin-whitaker.net permanent; } server { listen 80; server_name kevin-whitaker.net; access_log /home/admin/public_html/kevin-whitaker.net/log/access.log; error_log /home/admin/public_html/kevin-whitaker.net/log/error.log; root /home/admin/public_html/kevin-whitaker.net/public/; index index.html; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect false; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename.html) { rewrite […]