Articles of nginx

非SSL站点通过HTTPS访问时返回“无法连接”是正常的://

我只是谈论没有任何SSL证书的服务器(自签名或授权)。 是否正常的网站,没有任何关于SSL(默认configuration,干净安装的Apache / Nginx的)返回Unable to connect (Firefox)或refused to connect (铬)如果通过https访问(例如https://example.com )? 我的服务器确实是configuration错误吗?

Docker,Nginx和Supervisor nginx绑定失败

我正在尝试使用Nginx,Docker和Supervisor来安装服务器。 我面对的问题是,即使它工作,我可以看到index.html在我的浏览器,这个错误显示所有的时间: 2016/08/28 12:05:12 [emerg] 12#12: bind() to [::]:80 failed (98: Address in use) nginx: [emerg] bind() to [::]:80 failed (98: Address in use) dockerfile: FROM nginx:stable-alpine RUN rm -f /etc/nginx/conf.d/* && mkdir -p /var/www/app COPY config/nginx.conf /etc/nginx/conf.d/ COPY config/supervisord.conf /supervisord.conf COPY scripts /scripts RUN chmod -R 700 /scripts CMD [ "/scripts/start" ] 在/脚本/开始我有这个: #!/bin/bash […]

如何将所有HTTP请求redirect到HTTPS并将所有不存在的子域redirect到一个特定的域

我已经有一个工作configuration来redirect所有不存在的子域到一个特定的域。 现在我想添加一个configuration,将所有HTTP请求redirect到同一个域上的HTTPS。 这个configuration文件的子域redirect: # redirect any non-existent subdomain (blah.domain.de -> domain.de) server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 301 https://domain.de$request_uri; } 这是我尝试用于HTTP-> HTTPS的configuration: # redirect any HTTP request to its HTTPS address (http://domain.de/blub -> https://domain.de/blub) server { listen 80 default_server; listen [::]:80 default_server; server_name domain.de mail.domain.de admin.domain.de; return 301 https://$server_name$request_uri; } […]

Nginx在看似有效的path上返回404

我试图直接提供静态文件,像这样的位置块: location /static/ { alias /opt/graphite/webapp/content/; } 但是,当我提出任何匹配/ static /的请求时,我得到一个404错误,并在错误日志中这样的消息: 2016/09/14 09:28:47 [error] 66068#0: *4 open() "/opt/graphite/webapp/content/js/completer.js" failed (2: No such file or directory), client: my.ip.add.ress, server: server.domain, request: "GET /static/js/completer.js HTTP/1.1", host: "server.ip", referrer: "http://server.ip/composer?" 问题是在错误消息中给出的path是完全有效的。 该文件存在。 这不是声称权限被拒绝,所以它似乎不是一个权限问题。 代理应用程序的位置正常工作。 我不知所措,而类似的post似乎都属于套接字。 在OpenBSD 6.0上运行nginx 1.10.1。

将.htaccess转换为nginx重写

我一直在尝试将重写规则从.htaccess转换为nginx重写。 原始文件如下所示: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php?/$0 [PT,L] 转换 if (!-f $request_filename){ set $rule_0 1$rule_0; } if (!-d $request_filename){ set $rule_0 2$rule_0; } if ($rule_0 = "21"){ rewrite /.* /index.php?/$0 last; } 但是当我重新启动nginx时,我得到: nginx:[emerg]未知的“0”variables nginx:configuration文件/usr/local/nginx-1.8/conf/nginx.conftesting失败

Nginx – 将以前的所有子域的子目录redirect到主域的子目录

在Nginx中,我正在寻找将我的blog.example.com子域redirect到主网站( example.com/blog )的子目录。 blog.example.com子域在该子域下有许多博客post。 许多链接都指向这个旧的URL,我想为所有的blog.example.com/*链接(前一个子域的所有子目录链接)设置一个全部redirect,现在转到example.com/* (每篇文章应该位于example.com域的根目录中,而不是在单个post的/blog子目录中)。 我目前有子域redirect到example.com使用: server { server_name blog.example.com; location / { return 301 https://example.com/blog; } 任何人有任何build议为以前的子域的所有子目录设置301的提示? (仅供参考:所有页面在example.com上已经存在同名)。

Nginx规则可用时提供WebP图像

我想通过使用下面的代码服务器webp图像支持浏览器。 除了同一文件的.png和.jpg图像之外,我已经有.webp图像。 例如,如果有一个名为vacation.jpg的图像,我也有vacation.jpg.webp。 下面的代码工作,但它是覆盖我的其他位置块之前,我切换到CDN。 现在我正在使用CDN的代码块没有任何效果,没有响应的WEBP图像,也没有覆盖我的其他位置块。 这里是如何做到这一点: 添加到/etc/nginx/mime.types “image/webp webp” 添加到主要的nginx.conf文件中: map $http_accept $webp_suffix { default “”; “~*webp” “.webp”; } 添加到服务器块: location ~* ^/wp-content/.+\.(png|jpg)$ { add_header Vary Accept; try_files $uri$webp_suffix $uri =404; } 重新启动或重新加载nginx。 我的其他位置块的示例: 禁用热链接 location ~ .(ico|gif|png|jpe?g|svg|webp)$ { valid_referers none blocked example.com *.example.com; if ($invalid_referer) { return 403; } } 允许跨站点的静态域名文件 location ~ \.(ico|gif|png|jpe?|svg|webp|eot|otf|ttf|ttc|woff|woff2|ogg|js|css|font.css)$ […]

禁止nginx或PHP-FCGI创buildPHP文件

我在configuration为通过PHP-FCGI运行PHP的Debian Wheezy系统上运行nginx Web服务器。 除了适当地设置权限之外,出于安全原因,我想禁止nginx和PHP 创build符合location ~ \.php …规则的文件(或者相应地重命名其他文件),即以.PHP结尾的文件。 我怎样才能解决这个问题?

这个错误对5d意味着什么?

我有一个Web服务器HAproxy负载平衡和两个Nginx的+ PHP的FMP。 当我打开我的网站时,我看到了这个错误。 我知道504错误是什么意思,但为什么有5D?

nginx期望在哪里find它的模块?

nginx希望在哪里find它的模块的二进制文件? 例如,按照惯例,我应该在哪里安装模块nginx_ajp_module ?