我安装了nginx和HttpRealipModule来获取访问者的原始IP地址。我也将这个添加到我的nginx.conf中的http {}部分 set_real_ip_from 204.93.240.0/24; set_real_ip_from 204.93.177.0/24; set_real_ip_from 199.27.128.0/21; set_real_ip_from 173.245.48.0/20; set_real_ip_from 103.22.200.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 108.162.192.0/18; set_real_ip_from 190.93.240.0/20; real_ip_header CF-Connecting-IP; 但是,当我这样做 netstat -atun | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n 为了找出我的访问者的IP地址,我得到的所有IP都有ISP作为Cloudflare(我追踪这些IP)任何想法,为什么它不显示原始IP – 另一个问题,我想限制从我的网站下载时使用的并发连接数。如果我使用limit_conn 4; 它会做这项工作,但如果用户正在下载并尝试从浏览器访问网站,他/她得到503不可用。是否有办法限制连接,但仍允许用户同时浏览网站
我的PHP包括: location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; fastcgi_pass unix:/var/run/php5.socket; include /etc/nginx/fastcgi_params; } 我尝试允许按位置访问目录中的文件: location ~ /internal { allow IP; deny all; } 它的工作原理,但在这个目录中的PHP文件可以下载。
我正在windows 7下运行nginx 1.3.5,我需要直接从只读介质(CD或DVD)执行nginx,但是当我想运行它时,会失败并显示以下错误: nginx: [alert] could not open error log file: CreateFile() "logs/error.log" fail ed (5: Access is denied) 2012/08/28 13:52:46 [emerg] 5604#2864: CreateDirectory() "J:\nginx-1.3.5/temp/client_body_temp" failed (5: Access is denied) 其中J是我的CD-ROM驱动器号。 我已经改变nginx.conf完全禁用日志logging,但似乎仍然会尝试在'/ logs'文件夹中创build一个名为'error.log'的文件,并在启动时在'/ temp'文件夹中创build一些额外的临时内容,我想将“日志”和“临时”目录path更改为Windows临时文件夹(%temp%),但我没有任何想法,我该怎么做。 另外我想知道为什么nginx仍然创build“日志/ error.log”后禁用错误日志logging?
我一直在Ubuntu上使用gunicorn(现在的版本12.04)在nginx上运行一个django应用程序一段时间了,并且对结果感到满意。 我的问题是,我已经inheritance了我想在同一台服务器上运行的PHP网站。 任何人都可以给我一些build议,什么可能是最好的方式来添加PHP到我的服务器设置?
我有这个简单的Nginxconfiguration: server { listen 80; server_name example.com; rewrite ^(.*) http://www.example.com$1 permanent; } server { listen 80; server_name www.example.com; access_log /var/log/nginx/www.example.com.access.log; error_log /var/log/nginx/www.example.com.error.log; root /var/www/example.com/; location / { index index.html index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/example.com/$fastcgi_script_name; } } 现在是防止洪水(dos)攻击的时候了。 我想实施这两条规则: 1)我会阻止每秒3个请求的PHP请求 。 例: www.example.com/page.php www.example.com/page.php www.example.com/page.php www.example.com/page.php […]
我有一个服务器上的nginx + php-fpm,并且这些消息在2048个字符处被截断,在logging堆栈跟踪时渲染消息非常没有帮助:我看不到以下字段: 主持人(不感兴趣) 上游(不感兴趣) 请求(非常非常有趣) 服务器(不感兴趣) 客户端(不感兴趣,因为我们的架构总是127.0.0.1) 你如何克服这个问题? 你改变格式? 还是你find一种方法来克服这个愚蠢的2048字符限制,我听到硬编码? 或者禁用这个回溯?
我想在我的虚拟主机上使用共享的404页面。 以下是我的设置。 两个站点,每个都有自己的configuration文件在/ sites-available /和/ sites-enabled / www.foo.com bar.foo.com www目录设置为: www/ foo.com/ foo.com/index.html bar.foo.com/ bar.foo.com/index.html shared/ shared/404.html 除了根目录和服务器名称之外,/ sites-available中的两个configuration文件都是相同的: root /var/www/bar.foo.com; index index.html index.htm index.php; server_name bar.foo.com; location / { try_files $uri $uri/ /index.php; } error_page 404 /404.html; location = /404.html { root /var/www/shared; } 我已经尝试了上面的代码,并尝试设置error_page 404 /var/www/shared/404.html (没有以下位置块)。 我也双重检查,以确保我的权限设置为775所有文件夹和www中的文件。 当我尝试访问一个不存在的页面时,Nginx会提供我试图访问的虚拟主机的index.php文件。 任何人都可以指出我做错了什么? 谢谢!
是否有最佳做法(出于性能原因或以其他方式)select使用虚拟主机还是重写将子域指向根目录中的文件夹? 也就是说, www.domain.com -> public_html/domain.com/ sub.domain.com -> public_html/sub.domain.com/ 以上操作可以通过设置两台虚拟主机或者使用一台虚拟主机来完成,只需设置一个重写指向正确的子目录即可。 我的问题最初涉及到Apache,但是我想知道是否有最佳的Nginx的服务器块的做法。
我尝试启动我的Nginx,并在下面的命令后得到下面的错误: sudo /etc/init.d/nginx start Starting nginx: start-stop-daemon: unable to start /usr/local/nginx (Permission denied) 我的configuration文件是: user www-data www-data; worker_processes 1; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; access_log off sendfile on; tcp_nopush on; tcp_nodelay off; keepalive_timeout 10; gzip on; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; server […]
我想限制使用nginx访问(而且仅限于) http://mysite.com/protected.php 。 我可以尝试什么? 目前,我设法做到了,但php文件不再由php-fpm解释。 location ~ \.php($|/) { location ~ ^/ws(_dev)?\.php { auth_basic "User synchronisation webservice > please login"; auth_basic_user_file /home/symfony/instances/somesite/ws_access; } set $script $uri; set $path_info ""; if ($uri ~ "^(.+\.php)(/.*)") { set $script $1; set $path_info $2; } add_header X-Response-Host somesite.com; fastcgi_pass 127.0.0.1:8300; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /home/symfony/instances/somesite/service/web$script; fastcgi_param PATH_INFO $path_info; fastcgi_param […]