Articles of nginx

Nginx / git / fastcgi服务器不能正常工作

我使用FastCGI为Nginx上的Git服务器设置了所有必需的组件,并遵循几个教程的结合build议,最终完成此configuration: server { listen 80; listen [::]:80; server_name example.com www.example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; root /path/to/site; index index.html; server_name example.com www.example.com; # … Some ssl stuff here … location ~ /git(/.*) { auth_basic "Access denied"; auth_basic_user_file /path/to/auth; client_max_body_size 0; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; include fastcgi_params; fastcgi_param GIT_HTTP_EXPORT_ALL ""; […]

从Centos 7 EPEL`yum install nginx`中缺less`fastcgi_cache_purge`

我使用yum install nginx (来自EPEL回购)在Centos 7.1上yum install nginx 。 我根据https://codex.wordpress.org/Nginx设置WordPresscaching,并在开始时收到unknown directive "fastcgi_cache_purge"错误。 我没有fastcgi_cache_purge编译的模块,有没有从一个回购,我可以使用或我需要重新编译我自己的任何默认生成? [root@www1 ~]# nginx -V nginx version: nginx/1.6.3 built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) TLS SNI support enabled configure arguments: –prefix=/usr/share/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –http-client-body-temp-path=/var/lib/nginx/tmp/client_body –http-proxy-temp-path=/var/lib/nginx/tmp/proxy –http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi –http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi –http-scgi-temp-path=/var/lib/nginx/tmp/scgi –pid-path=/run/nginx.pid –lock-path=/run/lock/subsys/nginx –user=nginx –group=nginx –with-file-aio –with-ipv6 –with-http_ssl_module –with-http_spdy_module –with-http_realip_module –with-http_addition_module –with-http_xslt_module […]

nginx + php -fpm / hhvm具体的openbase_dir要求

我有这样的结构: user1 – site – public – functions.php user1 – site – public – functions.php appuser – app – index.php nginx将php设置为appuser – app – index.php,其中包括应用程序,然后是用户的各个functions.php 用户有ftp访问他们的公共目录 我怎么能限制该用户不能包括或修改他的公共目录下的任何东西,但应用程序/ index.php可以做任何事情

Gitlab找不到与nginx代理(负载平衡器)

我有以下的nginxconfiguration: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php index.html index.htm; location /git { proxy_pass http://134.103.176.101:10080; include proxy_params; } } 134.103.176.101是我的第二个托pipeGitlab的服务器。 所以当我浏览http:// server1 / git我得到我的gitlab。 问题是,所有的.pngs .ttf和.woff文件都找不到。 那是因为他突然从path中删除了/ git http://server1/assets/SourceSansPro-Regular-60f619fe2b3b48b193b9047abd7f8872.ttf Failed to load resource: the server 但是我已经将GITLAB_RELATIVE_URL_ROOT设置为/ git /在我的Gitlab安装。 为什么发生这种情况? 我怎样才能得到这个图像? 谢谢! 🙂 编辑:我已经find了重写缺less的请求的解决方法 #Rewrites the request, extracting a fragment […]

Nginx的高负载 – 低stream量的网站

有一段时间(也许每天一次?)我有一个10的平均负载。持续30分钟(我无法到达这个服务器上的任何网站),然后再次罚款。 我只是恰巧在服务器上通过SSH,做了一个htop。 主要是php-fpm: pool www和/user/sbin/mysqld进程。 我有Debian: Linux r3cwzg4q 2.6.32-042stab104.1 和最新版本的PHP,Nginx,Mysql和所有networking应用程序。 总共运行17个networking,stream量非常小(每天0 – 200个访问者 – 大多数在0 – 50个区域,只有一个networking200个)。 这是一个VPS,5GB内存,4个内核 – 正常负载在0.3左右。 有没有办法debugging哪个网站导致这种负载? 或者,如果它不是来自网站,它会从哪里来? (cron备份工作只在晚上,而不是现在)

fedora 22上的“404 not found”错误nginx / 1.8.0

我尝试运行已经在Nginx上的Apache服务器上运行的应用程序实际上,这是我第一次使用Nginx服务器 我的问题显示,当我需要访问Nginx Root Dir下的任何应用程序 我得到这个错误The page you are looking for is not found. 我的设置文件/etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size […]

意外的行为与嵌套的位置,别名和php-fpm上游

晚上好, 〜我想做什么〜 我需要一个默认的位置块匹配任何东西,我猜,这个块有它自己的根目录。 它必须提供任何静态文件,并解释其文档根或子文件夹内的任何PHP文件。 (我设置它,它接缝工作正常) 这里是我需要一些帮助:( … 在这个相同的服务器块里面,我想主持一个php symphony应用程序,当它碰到mydomain.foo/panel/区域。 所以我添加了一个^~ /panel/ location(uri以/ panel /开头) 我的问题是,try_files不像我所期望的(内部redirect到最后一个嵌套位置,以防uri不匹配嵌套位置)。 看下面的代码注释。 〜我的configuration是…〜 upstream phpfcgi { server unix:/var/run/php5-fpm.sock; } server { listen 80; server_name domain.tld; ## Default locations location / { root /home/me/sites/default/www; index index.php; location ~ \.php$ { include fastcgi.conf; fastcgi_pass phpfcgi; } location ~ /(.+) { try_files $uri $1 […]

使用NGinx缓慢的HTTP吞吐量

我有一个问题有一天,你们是非常有帮助的。 我已经在这个一个星期以来一直在绞尽脑汁。 基本上,我有几个nginx服务器反向代理在uwsgi上运行的python应用程序,当延迟(有点)很高时,服务非常慢的http响应。 每个服务器都有一个2Gb的互联网连接,而我自己的连接超过200Mb。 我离服务器50ms。 当我在同一个数据中心的服务器上运行apachebench时,结果如下: Document Length: 68093 bytes Concurrency Level: 1 Time taken for tests: 0.912 seconds Complete requests: 10 Failed requests: 0 Total transferred: 685380 bytes HTML transferred: 680930 bytes Requests per second: 10.96 [#/sec] (mean) Time per request: 91.217 [ms] (mean) Time per request: 91.217 [ms] (mean, across all concurrent requests) […]

Nginx反向代理上的rstudio-server

我在本地运行一个服务, rstudio-server 。 这项服务可以在我的机器本地IP,端口8787访问。 现在,我想从我的服务器访问这个服务,这个地址:rstudio.example.com(一个条目已经完成)。 我使用Nginx并创build了这个块: server { listen 80; listen 443 ssl; server_name rstudio.example.com; root /usr/lib64/rstudio-server/www; include /etc/nginx/ssl/rstudio.ssl.conf; location / { # rewrite ^/rstudio/(.*)$ /$1 break; #proxy_pass http://192.168.1.94:8787; proxy_pass http://unix:/run/rstudio-server/rstudio-server.sock; #proxy_redirect http://192.168.1.94:8787/ rstudio.myexample.com; proxy_redirect http://unix:/run/rstudio-server/rstudio-server.sock rstudio.myexample.com; #proxy_http_version 1.1; #proxy_set_header Upgrade $http_upgrade; #proxy_set_header Connection "upgrade"; } 我自愿让我尝试了所有的选项。 没有任何一种解决scheme可以让我连接到example.com上的服务。 我能看到的日志是: *5 epoll_wait() reported that client prematurely […]

url重写,nginx抛出404错误,没有任何错误日志

下面重写工作正常: rewrite ^/city/restaurants$ /city/listings/restaurants permanent; 但这不起作用 rewrite ^/city/restaurants$ /city/listings/restaurants last; rewrite ^/city/restaurants$ /city/listings/restaurants break; 我究竟做错了什么? 低于整个nginx服务器块 server { listen 80 default backlog=1024; server_name mydomain.com; client_max_body_size 20M; charset utf-8; keepalive_timeout 50; access_log /var/log/access_log main; error_log /var/log/error_log info; root /var/www/; index index.php index.phtml index.html; autoindex on; location ~ \..*/*\.php$ { return 403; } location ~^/sites/.*/private/{ return 403; […]