Articles of nginx

Nginx,proxy_cache和糟糕的行为应用程序(wordpress)

我一直在努力configurationNginx作为反向代理。 我大部分的机制工作,但我一直在为最后3天的战斗来控制caching标题和新手到Nginx这是让我疯狂… 它看起来像我没有得到如何位置块链起来。 我真的很感激一点帮助 我想要的是简单的 所有内容types的text/html有头Cache-Control: max-age=60, public, must-revalidate 所有的CSS / JS /图像等…有头Cache-Control: max-age=315360000, public 404和所有的错误没有caching控制 感谢有关如何完成这一任务的任何build议。 在这里我有代理设置(似乎按预期工作) proxy_cache_path /tmp/example levels=1:2 keys_zone=example:100m max_size=4g inactive=60m; proxy_temp_path /tmp/example/tmp; server { listen 80; server_name example.com; # is this realy needed? # Perhaps it should point to an empty folder root /var/www/vhosts/example.com/www; location ~ /\. { deny all; } […]

在nginx和ubuntu上启用模块

我有一台安装了nginx的服务器。 我想启用模块(特别是ngx_http_map_module)。 好的问题: 1)如何检查模块是否安装? 2)安装模块的工作stream程是什么? 唯一的办法是停止nginx,删除它,并重新编译与新模块? 3)停止nginx不是一个选项,因为有一个现场的网站已经。 任何其他选项添加模块?

不可能使用CloudFlare为WebP图像提供服务?

我想使用WebP格式优化我的网站上的一些图像。 Webp图像是高度压缩的JPEG和PNG与谷歌开发的algorithm的帮助。 但是,webp图像只能在现代的Chrome和Opera中显示。 如果浏览器支持webp,它将在Accept HTTP标题中指定image/webp 。 如果浏览器支持webp格式,并且如果在磁盘上存在webp版本的图像,那么检查nginx是个不错的主意,如果是这样 – 提供webp图像,如果没有,则提供默认图像。 例如: http://example.com/dog.png , Accept: image/webp, image/png, image/jpeg 。 nginx必须发送dog.png.webp http://example.com/dog.png , Accept: image/png, image/jpeg 。 nginx必须发送dog.png 在这个nginxconfigurationhttps://github.com/igrigorik/webp-detect/blob/master/nginx.conf和https://github.com/kavu/sprockets-webp#nginx中可以find更多的解释 没关系。 但是我正在使用CloudFlare CDN来加速资产交付。 有了这样的图像服务条件,我们必须添加头Vary: Accept所以caching浏览器和代理将正常工作。 但有个问题! CloudFlare仅支持Vary: Accept-Encoding 。 这在这里描述。 客户端将获得由CloudFlare第一(WebP或常规)caching的图像版本,如果客户端不支持WebP,它将不会看到图像,这是可怕的。 有没有解决办法?

关于ubuntu服务器lts的发布升级

我正在运行一台运行Ubuntu Server 12.04 LTS的云服务器,我想知道如果我做一个do-release-upgrade到新的稳定版Ubuntu Server 14.04.3 LTS 。 由于我运行一个php-5.3 , php-fpm和MYSQL的NGINX服务器,我的问题是: 所有这些软件包都自动更新到最新的稳定版本与新的Ubuntu版本兼容? 或者我会有问题? 重新安装等… 希望这是有道理的,并find答案…提前感谢任何答复。 PS:我害怕失去所有我的nginxconfiguration以及我的数据库…

nginx连接套接字失败没有文件或目录与Django和uwsgi

我正在尝试使用本教程: Digital Ocean,使用nginx和uwsgi部署一个djangonetworking应用程序。 我按照教程一步一步,这些是我的configuration文件: /etc/uwsgi/sites/picknbox.ini: [uwsgi] project = picknbox # Virtual environment name in home directory base = /home/picknbox # Home directory path chdir = /home/picknbox/picknbox/picknbox # Virtual Env Directory home = /home/picknbox/picknbox #Django Project Directory with manage.py$ module = picknbox.wsgi:application # project name master = true processes = 5 socket = /home/picknbox/picknbox/picknbox/picknbox.sock chmod-socket = […]

ELB nginx – redirect循环

我有nodejs应用程序(在本地工作正常)后面的nginx与以下configuration: 00_elastic_beanstalk_proxy.conf upstream nodejs { server 127.0.0.1:8081; keepalive 256; } server { listen 8080; return 301 https://$host$request_uri; location / { proxy_pass http://nodejs; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } gzip on; gzip_comp_level 4; gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascrip$ } https.conf server { […]

nginxredirect/到/ v2 /

我有一个nginx的位置定义如下: location / { alias /usr/share/nginx/myapp/dist/; gzip_static on; # Media: images, icons and fonts location ~* \.(?:jpg|jpeg|png|ico|otf)$ { expires 2M; access_log off; add_header Cache-Control "public"; } # CSS, HTML and Javascript location ~* \.(?:css|js|html)$ { expires 4h; access_log off; add_header Cache-Control "public"; } } 但由于某种原因,许多用户没有得到我最后的index.html更新。 由于这是至关重要的,很多用户抱怨我想重新确定/(/index.html,/#/ myTeam)到/ v2 /(/v2/index.html,/ v2 /#/ myTeam)的每个请求。 所以生病肯定用户caching不是一个问题。 Iv'e创build了一个名为/ v2 […]

Drupal 8 Nginx错误没有这样的文件或目录的任何路线

我在Nginx + PHP7 + PHP 7 FPM的Docker上运行Drupal 8.1.2,并且链接到另一个基于Alpine Linux的PostgreSQL Docker镜像。 在成功运行Drupal安装(在core / install.phpurl)并设置网站名称,pipe理员名称和其他细节之后,它在我点击提交button后立即抛出404。 我只能访问/update.phpurl。 错误日志 : 2016/06/17 16:32:49 [error] 11#0: *80 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 172.17.0.1, server: _, request: "GET /favicon.ico HTTP/1.1", host: "localhost" 2016/06/18 11:47:32 [error] 13#0: *40 open() "/var/www/html/user/1" failed (2: No such file or directory), client: […]

自定义域名和通配符DNS

我有一个Web应用程序使用用户configuration文件的子域(例如noodles.example.com)。 我在Nginx中configuration了一个通配符DNS。 一切工作正常。 用户如何能够将自己的域名指向我的服务器IP地址并获得他的个人资料? 这种情况将如何工作?

在启用站点的情况下configurationnginx log_format

我有一个我想启用的log_formatconfiguration。 问题是我们的安装在nginx目录中添加了一个文件到sites-enabled(或者conf.d),我们不会碰nginx.conf本身 我想保持这种方式(更容易升级nginx版本等) 根据我的理解, log_format只能在nginx.conf中的http部分完成 我有什么select?