我们的网站基于Angular,它几乎完全基于JavaScript,因此我们需要为Googlebot提供静态HTML快照,以便抓取我们。 目前,我们有这个实施: location / { # Rewrite rules for the Google and Bing bots and other crawlers. # Serves static HTML from /snapshots when a URL is requested if ($http_user_agent ~ (Googlebot|bingbot|Screaming)) { rewrite ^/(.*)$ /snapshots/$1.html break; } } 这在大多数情况下都能正常工作,但是如果Google要求一个URL,例如: http://site.com/support/contact/ : http://site.com/support/contact/ ,它将被重写成: http://site.com/support/contact/.html : http://site.com/support/contact/.html显然会返回一个404。我需要更改configuration以在URL末尾删除正斜杠,以确保返回: http://site.com/support/contact.html : http://site.com/support/contact.html 这怎么能在nginxconfiguration中实现呢? 因此,我们在网站站长工具中看到了数百个404错误。 谢谢!
我知道这不是一个独特的问题,但也许这种performanceforms是独一无二的。 在其他地方find的答案不符合我认为是我的情况。 我有一个托pipe几个网站的盒子,尽pipe我没有发现function问题,但是我发现这个消息在我的Nginx错误日志中几乎遍布每个站点。 我读的所有内容都指向了我的FastCGI参数,特别是SCRIPT_FILENAME ,但是我的价值似乎与SCRIPT_FILENAME的build议是一致的: fastcgi_param SCRIPT_FILENAME $request_filename; 我读了错误的build议? 我也注意到,在某些情况下(但不是全部) ,日志中的host值是Alogging指向的那个,但不是Nginx正在侦听的那个。 任何想法可能会发生什么? 在404的情况下,这个错误是“预期的”,也许呢?
我有一个Python 3 bottle.py应用程序,我安装到虚拟环境(让PIP自动获取依赖)。 我试图让它在我的覆盆子pi下运行在nginx和uwsgi下。 当我运行nginx和uwsgi时,访问http://localhost/icecrate导致“uWSGI Error Python application not found”。 我假设这意味着nginx正确连接到uwsgi,并且它是uwsgi无法find应用程序。 但是,如果我用uwsgi –http 0.0.0.0:8080 /etc/uwsgi/apps-enabled/icecrate.ini运行应用程序,那么http://localhost:8080会给我应用程序,这表明uwsgiconfiguration至less是充足。 我一直在search谷歌和文档几个小时的解决scheme。 我不知道我在这里做错了什么。 在/ etc / nginx的/网站可用/ icecrate server { listen 80; server_name raspberrypi; access_log /home/icecrate/logs/access.log; error_log /home/icecrate/logs/error.log; location /icecrate { uwsgi_pass unix:///tmp/icecrate.sock; include uwsgi_params; } } /etc/uwsgi/apps-available/icecrate.ini [uwsgi] vhost = true plugins = python3 socket = /tmp/icecrate.sock master = true […]
我正在试图确定在什么是木偶和什么是“应用程序”的一部分之间画线。 我有点困惑的地方是nginx conf.d文件。 在Apache中,我将这些文件标记为.htaccess,因此是应用程序的一部分。 但是,在nginx中没有.htaccess文件; 他们必须进入conf.d目录并且服务器退回。 不够公平,但是在打包应用程序和用puppet部署服务器configuration时,我发现服务器configuration和应用程序之间的界线比较模糊。 如果我把文件放在应用程序包(我们使用RPM),那么我在应用程序中有服务器configuration。 但是,如果我把这些文件放在puppet中,应用程序作者希望做一个修改(添加另一个位置,或者重写等),那么我必须更新puppet,现在下一个版本的应用程序依赖于puppet release 。 看起来像鸡和鸡蛋问题给我。 最适合放置这些conf.d文件的地方是puppet还是应用程序RPM?
我有nginx设置为一组apache(LAMP)后端监听端口8080的反向代理。 我还configuration了每个后端服务器的mod_rpaf.conf文件,以包含nginx服务器的代理IP: <IfModule mod_rpaf.c> RPAF_Enable On RPAF_ProxyIPs 127.0.0.1 192.168.0.1 # <- nginx server IP RPAF_Header X-Forwarded-For RPAF_SetHostName On RPAF_SetHTTPS On RPAF_SetPort On </IfModule> 我怎样才能configurationhttpd.conf拒绝任何不是来自nginx的连接? 我已经尝试了以下内容: <Directory "/var/www/html"> Order allow,deny Allow from 192.168.0.1 Allow from 127 Deny from all </Directory> 但是这似乎限制了对nginx代理本身以及任何其他IP的访问。 这是由于mod_rpaf转发客户端IP吗? 如果是的话,我该如何得到这个?
有时,nginx不会将任何数据发送回浏览器(Chrome中的ERR_EMPTY_RESPONSE )。 在检查服务器的error.log,我发现这些奇怪的消息: 2013/10/20 23:57:40 [alert] 29146#0: *35 pread() read only 4653 of 4656 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost" 2013/10/20 23:57:45 [alert] 29146#0: *36 pread() read only 4653 of 4656 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET […]
在Arch Linux上,出于某种原因,当我尝试用命令“systemctl start nginx”启动nginx时,它失败了,这是“systemctl status nginx”的输出: Loaded: loaded (/etc/systemd/system/nginx.service; enabled) Active: failed (Result: exit-code) since Wed 2013-10-30 16:22:17 EDT; 5s ago Process: 9835 ExecStop=/usr/bin/chroot –userspec=http:http /home/nginx /usr/bin/nginx -g pid /run/nginx.pid; -s quit (code=exited, status=126) Process: 3982 ExecStart=/usr/bin/chroot –userspec=http:http /home/nginx /usr/bin/nginx -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 10967 ExecStartPre=/usr/bin/chroot –userspec=http:http /home/nginx /usr/bin/nginx […]
我有以下configuration: location ~ ^/((index\.php|robots\.txt|admin|static|uploads|api)(/.*)?)$ { proxy_set_header Host $http_host; proxy_pass http://localhost:1337/$1?$args; } 我想将转义百分比应用到$1 ,所以例如/admin/foo%20bar会转发/admin/foo%20bar而不是/admin/foo bar 。 我怎样才能做到这一点?
所以我使用Nginx(1.4.3)来反向代理域和子域。 我安装了SSL证书来处理主域(example.com)和几个子域(可以说test.example.com和mail.example.com)。 所以我自然使用一个301返回将http请求移动到https。 server { listen 80 default_server; server_name example.com www.example.com; return 301 https://example.com$request_uri; } 很好用。 但是,如果我在HTTPS SSL Certs下引入另一个不需要的子域(因为我没有通配证书并且不需要此子域)。 尽pipeserver_name已经被隐式设置了,Nginx似乎还是应用了301。 由于它是1.4.3,我把它们分解在conf.d文件夹中。 我认为这是因为如果我清除我的浏览器caching,并导航到新的子域(sd.example.com),它工作正常,不重写为https。 但是,如果我去主网站(example.com)重写踢,我发送到https://example.com ,没有问题。 但是,如果我尝试返回到sd.example.com,则会被重写为https://sd.example.com,并且会popup一个大红色的错误消息。 任何想法为什么发生这种情况? 我宁愿停止在这一个敲我的头。
我正在使用WPN-XM (与Nginx,MariaDB,PHP和OPENSSL堆栈),并试图在HTTP/HTTPS服务器中设置OpenSSL 。 我在这里按照NGINX的指示,我的服务器启动/停止没有错误。 这是我的nginx.conf与“双服务器”: server { listen 80; listen 443 ssl; server_name localhost; root www/login; # ssl properties ssl_certificate ../../../bin/openssl/certs/cert.pem; ssl_certificate_key ../../../bin/openssl/certs/cert.key; ssl_session_timeout 5m; ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; log_not_found off; charset utf-8; access_log logs/access.log main; # handle files in the root path /www location / { index index.php index.html […]