Articles of nginx

无法加载文件或程序集fastcgi-mono-server4

我正在尝试使用Mono托pipeASP.NET Web窗体应用程序。 我已将Mono 3.0.7和XSP 2.10.2从源代码安装到/ usr / bin目录中。 然后我用下面的命令启动了单声道服务器: fastcgi-mono-server4 /applications=www.example.com:/:/var/www/example/ /socket=tcp:127.0.0.1:9000 /verbose=True /printlog=True 但是,当我浏览到http://www.example.com ,出现502错误网关错误。 我看到logging了以下错误: [2014-11-10 15:30:01Z] Error Failed to process connection. Reason: Could not load file or assembly 'fastcgi-mono-server4, Version=2.10.2.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified. 那么为什么它找不到文件呢? 我尝试添加/usr/bin到我的MONO_PATH ,但是没有帮助。 这是我的nginxconfiguration: server { listen 80; […]

nginx和SSLredirect

我有一个我用作代理的nginx服务器。 我想要所有的请求作为正常的http请求转发,期望请求到api.mydomain.org,我希望与ssl / https运行的请求。 这与以下工作正常: server { listen 80; server_name api.mydomain.org; return 301 https://api.mydomain.org$request_uri; } server { listen 443; server_name api.mydomain.org; location / { proxy_pass http://backend; 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; proxy_set_header X-Forwarded-Proto https; } ssl on; ssl_certificate /etc/nginx/ssl/api.mydomain.org/server.crt; […]

Apache到Nginx的转换(新手)

我有一个PHP的Nginx Web服务器设置,我想在Nginx上移动,我想将这些.htaccess规则转换为nginx.conf文件: RewriteRule ^blog(|/)$ /data/core/site/blog.php RewriteRule ^blog/post(|/)$ /data/core/site/blogpost.php 到目前为止,这是我的: location /blog { rewrite ^(.*)$ /data/core/blog.php last; } 但是,如果我访问该页面( http://example.com/blog ),它给我的文件下载,我想它服务器的PHP和显示内容,我将如何解决这个问题? 完整的Nginxconfiguration:(在Windows上使用Winginx软件包): server { listen 127.0.0.1:80; server_name localhost; root home/localhost/public_html; index index.php; log_not_found off; #access_log logs/localhost-access.log; charset utf-8; location ~ /\. { deny all; } location = /favicon.ico { } location = /robots.txt { } location […]

nginx子目录到子域icingaweb2

我现在有icinga2与新的icingaweb2用户界面。 它默认为子文件夹/ icingaweb,如下所示: location ~ ^/icingaweb/index\.php(.*)$ { # fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/share/icingaweb/public/index.php; fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb; } location ~ ^/icingaweb(.+)? { alias /usr/share/icingaweb/public; index index.php; try_files $1 $uri $uri/ /icingaweb/index.php$is_args$args; } 如果我将第一个位置块更改为: location / { 它显示login页面减去所有的CSS。 我怎样才能得到它从一个子域ex前工作。 icinga.example.com? 为了logging我知道的文件的其余部分是正确的,比如server_name,listen root等 提前致谢。 服务器块请求: server { listen 80; server_name icinga.example.com; root […]

根据GET查询更改proxy_cache_valid值

我目前正试图设置一个nginxcaching,应该caching一个位置很长一段时间,但如果查询参数只存在几分钟。 所以基本上: http://example.com/mypath -> long cache http://example.com/mypath?param=1 -> short cache 我目前的configuration看起来像这样: location "~^(/mypath)" { proxy_cache example.com_my_cache_http; proxy_cache_valid 404 15m; … } 我不能使用不同的位置,因为位置不能匹配查询参数,我曾尝试使用if (我知道这是不好的做法) if ($args ~ param) { proxy_cache example.com_my_cache_http; proxy_cache_valid 404 15m; } else { proxy_cache example.com_my_cache_http; proxy_cache_valid 404 2d; } 这导致: Testing nginx configuration: nginx: [emerg] "proxy_cache" directive is not allowed here 我也尝试使用variables: […]

nginx域使用SSL证书监听但不可访问

我有多个域名和多个使用SSL证书运行在Nginx下的域名。 所有的域基本上都使用完全相同的configuration,取代当然的名字,除了我有SSL设置指定的启用HTTPS的域。 在这两个域之间,configuration对于SSL来说也是一样的,除了密钥等的文件名之外。 每个网站也运行在自己的专用IP上。 (他们全部) 我所有的非SSL网站都工作得很好。 我可以访问他们没有任何问题。 我的所有SSL站点都从CloudFlare获得521错误。 (严格的SSL开启,只是fyi) 我之前build立的一个领域工作得很好。 即使我删除了另一个启用了SSL的域,它现在仍然不起作用。 我所做的唯一configuration更改是添加一个也使用SSL证书的新域。 当我用nginxtestingconfiguration时,它表示一切正常。 当我检查netstat时,我可以看到443的监听IP。我在/ var / log / syslog或nginx的访问和错误日​​志中看不到任何错误。 主要是nginx.conf user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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 […]

Nginxcaching没有更新

所以我的同事给我们设置了一个新的caching代理系统,然后立即去度假。 现在,我收到了来自开发人员/devise师的抱怨,许多静态资源被caching的时间比我看到的任何configuration都要长得多。 例如,某个徽标文件在13日之后已经被更改,但是从9日开始的版本仍然被返回,尽pipe设置为: proxy_cache_valid 200 1h; 应该只caching1小时。 据我可以看到上游服务器给Nginx的标题Expires: Sat, 14 Feb 2015 19:33:58 GMT ,caching到期正在运行,不pipeLast-Modified:标题已经改变的事实。 我已经查看了上游服务器的日志,并且代理没有尝试检查文件的状态。 我怎样才能让Nginx检查更新的内容? 来自caching的响应标题: # curl -v -XHEAD 'http://foo.company.com/inc/skins/pt-1r/schemes/default/img/logo.png' * About to connect() to foo.company.com port 80 (#0) * Trying 1.2.3.4… connected * Connected to foo.company.com (1.2.3.4) port 80 (#0) > HEAD /inc/skins/pt-1r/schemes/default/img/logo.png HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.1 Basic […]

2个具有相同视图和模板的网页的服务器响应时间不同?

我最近面对一些网页的服务器响应时间大大增加(响应时间在10-20秒范围内)。 例如,对于页面http://www.edmhunters.com/afrojack/ – 谷歌网页速度testing表示,服务器响应迅速(这意味着它在200毫秒以下)。 对于具有相同视图和模板的另一个页面 – http://www.edmhunters.com/skrillex/ – 谷歌网页速度testing表示,服务器响应时间是10.3秒。 假设错误在我的服务器configuration中,并且与代码本身无关,是否安全? 我的网站是一个Django应用程序,使用DigitalOcean(1GB内存,30GB SSD磁盘,Ubuntu 14.04 x64)托pipe的Nginx,Gunicorn,PostgreSQL和Memcached。 以下是我对Nginx的一些configuration设置 worker_processes 4; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; gzip on; server { listen 80; client_max_body_size 4G; server_name www.edmhunters.com; keepalive_timeout 5; } } 对于Gunicorn,我已经把工人数量设置为3.对于这里有什么可能是错误的任何build议? 当谈到服务器托pipe时,我几乎是一个小菜鸟,这件事让我感到莫名其妙。

使用nginx服务登陆页面。 无法获得“/”的工作,而其他url工作正常

我正在尝试为我的网站(例如example.com)设置一个login页面,并且当有人在浏览器中键入“example.com”时,我想将自己的html作为要加载的页面进行加载。 我正在使用nginx作为我的networking服务器,但无法做到这一点。 我总是得到默认的“欢迎nginx”页面,而不是我的HTML。 这是我的nginx conf: #user nobody; worker_processes 1; error_log /var/log/nginx/error.log; events { worker_connections 1024; } http { include mime.types; # include /usr/local/nginx/sites-enabled; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name example.com; access_log /var/log/nginx/access.log; location / { root /data/www; index test.html; } location /images{ root /data; } error_page 500 502 503 504 […]

基于全局variables在Nginx中设置server_name

我有一个nginx的服务器,运行一个生产站点,在不久的将来应该换成一个新的站点。 为了做好准备,我正在准备运行新站点所需的所有configuration。 我想要的是在主要的nginx.conf中有一个全局variables,它包含一个string(例如'old'或'new'代表在主域example.com上活动的站点,而另一个站点在其他站点上other.example.com 。 我试过了: 在nginx.conf http{ … set $site_in_production 'new'; … include /etc/nginx/conf.c/*.conf; } 在/etc/nginx/conf.d/example.com.conf server{ … if($site_in_production='new'){ server_name other.example.com; } else { server_name example.com www.example.com; } … } 在/etc/nginx/conf.d/new.example.com.conf server{ … if($site_in_production='new'){ server_name example.com www.example.com; } else { server_name other.example.com; } … } 但是,当运行一个configtest我得到这个错误: nginx: [emerg] "set" directive is not allowed here in […]