Articles of nginx

域名在nginx中redirect到错误的站点,在configuration文件中有多个站点

我有2个网站在nginx上设置,正确的应该加载取决于哪个域被访问。 例如:website1.com website2.com 但是,访问这两个域时,它们都会加载website1.com。 我的configuration有什么问题? 两个configuration都在启用网站的单独文件中 website1.comconfiguration server { listen 80; listen [::]:80 ipv6only=on; root /var/www/website1.com; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name website1.com; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; # […]

nginx和php-fpm“主脚本未知”

闻起来就像一个重复的,我知道,但我现在已经尝试了5次这个安装程序,但我仍然无法得到这个工作。 大多数的configuration与chroot和多服务器等复杂,但我现在已经减less到最简单的configuration可能。 我想了解如何使用nginx以最简单的forms设置fpm …请耐心等待。 当前设置: CentOS 7 64位 nginx 1.8.0来自Nginx的回购 从Remi php56的PHP 5.6 除了/etc/nginx/conf.d/default.conf location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 添加和修改/etc/php-fpm.d/www.conf listen = /var/run/php-fpm/php-fpm.sock listen.owner = nginx listen.group = nginx listen.mode = 0660 新增文件/usr/share/nginx/html/info.php <?php phpinfo();?> 开始这两个服务 systemctl start nginx.service systemctl start php-fpm.service 最后tail -f /var/log/nginx/error.log 当读取来自上游的响应标题时,客户端:xx.xxx.xxx.xxx,服务器:本地主机,主机名称为“ […]

Nginx HHVM WordPress问题与PHP执行在一个中间子目录

我的网站有一个奇怪的情况,仍在AWS开发中。 我有nginx 1.9.9与HHVM 3.6.6-1.amzn1.x86_64在t2.micro。 这是不公开的。 我在域的根目录下有一个自定义的书写网站,我在/ blog目录中有Wordpress,WordPress的pipe理员在/ blog / wp-admin。 自定义网站有各种文件,包括index.php。 WordPress的index.php和博客目录中的其他所有东西,wp-admin也使用index.php。 我可以加载自定义网站,它完全有效。 WordPress的pipe理员完全有效。 WordPress的博客主屏幕/故事列表完全有效。 问题是,当我点击任何博客文章的链接,以查看它的全部显示自定义网站主页索引。 所以,换一种说法 http://www.example.com/index.php – custom website works http://www.example.com/blog/index.php – blog index works http://www.example.com/blog/2015/storyname – story load doesn't work with permalink %postname% regardless of text in post name – http://www.example.com/index.php loads http://www.example.com/blog/2015/?p=96 – story load works http://www.example.com/blog/wp-admin/ – admin works 当我点击故事链接时,我得到的页面内容与我点击http://www.example.com/index.php的页面内容相同,只是图片不会像使用相对URL一样加载 […]

以recursion方式保护Nginx目录

如何保护Nginx中某个特定目录( – >recursion)中的所有文件和其他导引文件,使其无法通过Web访问?

NGINX不在/ etc / default / nginx中应用variables

我已经更新了我的服务器之一从debian 6到debian 8.以前一切工作正常。 现在,NGINX无法从正确的configuration开始。 我将/etc/default/nginx为如下所示: DAEMON_OPTS="-c /etc/nginx/my.nginx.file.conf" DAEMON_ARGS=$DAEMON_OPTS 这应该使NGINX开始使用在/etc/nginx/my.nginx.file.conf设置的自定义configuration文件而不是标准的/etc/nginx/nginx.conf 。 我检查了init.d脚本,它有: # Include nginx defaults if available if [ -r /etc/default/nginx ]; then . /etc/default/nginx fi 但似乎并不适用。 如果我删除文件/etc/nginx/nginx.conf并保留我的configuration文件,我会得到以下内容: # /etc/init.d/nginx start [….] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details. failed! # systemctl status nginx.service ● […]

Nginx的HTTP不工作 – 下载一个名为“下载”的文件

如果我使用https访问我的nginx网站,它正在工作,但用http下载一个名为“download”的文件(没有任何扩展名),57字节并用记事本等打开它只显示乱码的东西。 这是我的虚拟主机configuration: server { server_name www.domain.com domain.com; listen 80; return 301 https://domain.com$request_uri; } server { server_name www.domain.com listen 443 ssl; /* SSL Stuff */ return 301 https://domain.com$request_uri; } server { server_name domain.com; index index.php index.html index.htm; listen 443 ssl; root /usr/share/nginx/domain.com; /* SSL Stuff */ location / { try_files $uri $uri/ /index.php?$args; } location ~ […]

Nginx的反向代理很慢

我有Nginx作为Apache的反向代理工作,但所有网站都需要很长时间才能加载。 另外我觉得Nginx并没有像预期的那样工作。 我确定虚拟主机configuration有问题。 以下是我使用的虚拟主机configuration: server { root /home/username/public_html; listen xx.xx.xx.xx:80; server_name domain.com www.domain.com; access_log /dev/null; error_log /usr/local/nginx/logs/vhost-error_log warn; index index.php index.html index.htm; location / { location ~.*.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|woff|ttf|svg|eot)$ { gzip_static on; proxy_cache nginx-cache; root /home/username/public_html; tcp_nodelay On; tcp_nopush On; access_log /dev/null; log_not_found Off; expires 7d; } error_page 404 403 502 505 506 = @apachebackend; add_header X-Cache […]

我可以在重新加载/重新启动时自动使Nginx OCSP主存证书?

有没有办法让Nginx每次configuration重新加载或重新启动时主动提供 OCSP Stplet证书? 或者,Nginx是否可以设置为在重新加载或重新启动时保存已装订的证书而不是丢弃它们? 重新加载或重新启动Nginx似乎会清除所有caching的OCSP装订证书。 我testing了OSCP装订,并在运行Nginx 1.11.4的Ubuntu 16.04.1服务器上工作,并使用Certbot的OCSP必备 TLSfunction扩展。 我的问题是,重新加载或重新启动Nginx时,合并的响应不会保存,而第一个访问者会看到一个错误页面(这是服务器尚未装订的“必须装订”证书的预期结果)。 我必须访问服务器托pipe的每个网站,并重新加载它们几次,而Nginx自动OCSP装订证书,然后一切开始工作,直到下一次重新启动。 我想自动化这一步或完全避免它。

让我们encryption的中间证书

我已经build立了让我们在我的服务器上encryptionencryption,然后在同一台服务器(使用nginx的ubuntu服务器16.04)上build立一个邮件服务器(dovecot和postfix)的教程。 在这个过程中,我还为该域创build了两个电子邮件地址,我希望通过邮件客户端Mail来使用。 但是,我收到错误“无法validation帐户名称或密码”,并在http://www.checktls.com/perl/TestReceiver.pl我收到以下错误: [001.075] Cert NOT VALIDATED: unable to get local issuer certificate [001.075] this may help: What Is An Intermediate Certificate [001.075] So email is encrypted but the domain is not verified [001.075] ssl : scheme=ldap cert=140396633026752 : identity=mail.mysite.com cn=mysite.com alt=2 mysite.com 2 www.mysite.com [001.075] Cert Hostname DOES NOT VERIFY (mail.mysite.com != mysite.com) [001.076] […]

Nginx重写地址不会自动添加参数

原始请求地址: www.example.com/index.php?r=mobile/receive/index 重写的请求地址: www.example2.com/newindex.php?r=mobile2/receive2/index2 这是我自己的configuration: if ($args ~* "^r=mobile/receive/index") { rewrite ^ "http://www.example2.com/newindex.php?r=mobile2/receive2/index2"; } 但重写地址的结尾是这样的: http://www.example2.com/index.php?r=mobile2/receive2/index2&r=mobile/receive/index 你看到我的问题吗? 重写的地址是自动添加的,但这不是我想要的。 相同的参数键将导致后盖正面。