我有以下重写nginx的规则。 规则似乎无法正常工作,例如游戏规则应该将http://thegamesdb.net/game/2/重写为http://thegamesdb.net/index.php?tab=game?id=2当我导航到/游戏/ 2 /浏览器正在下载一个名为简单download的文件hover。 我的重写规则如下: # nginx configuration location /game { rewrite ^/game/([0-9]+)(/?)$ /index.php?tab=game&id=$1 break; rewrite ^/game-edit/([0-9]+)(/?)$ /index.php?tab=game-edit&id=$1 break; } location /search { rewrite ^/search/([a-z0-9\-\ /\+]+)(/?)$ index.php?tab=listseries&string=$1&function=Search break; rewrite ^/search(/?)$ /index.php?tab=listseries&function=Search break; } location /browse { rewrite ^/browse/([0-9+]*)(/?)$ /index.php?tab=listplatform&stringPlatform=$1&function=Browse+By+Platform break; } location /platform { rewrite ^/platform/([0-9]+)(/?)$ /index.php?tab=platform&id=$1 break; rewrite ^/platform/([a-z0-9\-]+)(/?)$ /index.php?tab=platform&alias=$1 break; rewrite ^/platform-edit/([0-9]+)(/?)$ /index.php?tab=platform-edit&id=$1 […]
我有2个网站, http://localhost/bb – phpbb http://localhost/dp – Drupal 我希望将$server_name/bb/ucp.php?mode=logout&sid=xxxxxredirect到$server_name/dp/user/logout ,sid应该被忽略。 我试过这个: location /bb/ { index index.php; if ($query_string ~* "mode=logout$") { rewrite ^/bb/ucp\.php http://$server_name/dp/user/logout redirect; } } 这似乎不工作。 谁能帮忙? 谢谢。 我也试过这个: location /bb/ { index index.php; if ($arg_mode ~* "logout") ## and = instead of ~* too. { rewrite ^/bb/ucp\.php http://$server_name/dp/user/logout redirect; } } 但它也不起作用。 当前整个configuration: […]
看来,清漆丢失或没有正确validationcaching。 当我尝试清除我的caching,我得到200 OKcaching成功清除,但我的网页不更新。 我只是简单地对我的footer.php进行HTML修改(使用WordPress),但是他们没有出现。 我检查了我的标题,他们如下所示: HTTP/1.1 200 OK Server: nginx/1.6.0 Content-Type: text/html Last-Modified: Wed, 23 Apr 2014 18:47:17 GMT ETag: "53580ab5-2" Content-Length: 2 Accept-Ranges: bytes Date: Fri, 10 Oct 2014 15:53:28 GMT X-Varnish: 21166333 Age: 0 Via: 1.1 varnish Connection: keep-alive X-Varnish标题中缺less“填充caching的请求的ID”。 所以我检查了标题,直接从我的VPS托pipe我的网站运行命令,它似乎工作正常: HTTP/1.1 200 OK Server: nginx/1.6.0 Content-Type: text/html; charset=UTF-8 Vary: Accept-Encoding X-Powered-By: PHP/5.4.33 […]
我知道这个问题已经被无数次的问到了。 仍然不能让我的工作与我目前看到的答案。 我试图强制redirecthttp到https与nginx。 当我访问https // subdomain.example.com时,一切正常,但访问http://subdomain.example.com给了我 "This Webpage has a redirect loop" 我试过了 rewrite ^(.*) https://$host$1 permanent; 和 return 301 https://www.mydomain.com$request_uri; 试着 proxy_set_header X-Forwarded-Proto $scheme; 没有解决这个问题。 请问我该如何解决这个无限循环问题? 这是我的nginx.conf upstream unicorn { server unix:/tmp/unicorn.example.sock fail_timeout=0; } server { server_name subdomain.example.com; listen 80; return 301 https://$host$request_uri; root /home/deploy/apps/example/current/public; location ^~ /assets/ { gzip_static on; expires max; add_header […]
PHP-FPM 5.6和Nginx 1.6.2毫无疑问会提供最大的性能,至less在速度上是明智的。 所以,我想知道是否有任何优点/缺点添加清漆caching,以获得可能几乎没有更多的速度。 我读过很多博客,说nginx + varnish单独是有点矫枉过正,但我还没有得到一个反馈,可以certificate这一点。
我目前正在为我们公司设置新的服务器,而且我们正在开发很多不同的应用程序,现在我们要在wp.domain.com/app1,wp.domain.com/app2等所有的wordpress应用程序中。 默认不工作的原因是因为我们想为所有的应用程序使用%postname%permalink。 我目前正在通过对每个子文件夹进行重写来进行pipe理,但是我宁愿用一个location块来重写每个子文件夹,所以每当我们上传一个新的应用程序到服务器时,我都不必编辑服务器块。 我们也有可能上传到子目录,例如wp.domain.com/appgroup1/app3,wp.domain.com/appgroup1/app6等。 这是我的wp.domain.comconfiguration: server { listen 80; root /usr/share/nginx/html/wp; index index.php index.html index.htm; server_name wp.domain.com; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location ~ /(.*)/ { index index.php; try_files $uri $uri/ /$1/index.php?$args; } […]
我在$ uri中有一个带有语言前缀的网站,例如: http://www.example.com/en/some/content http://www.example.com/ru/novost 可悲的是,由于我使用的框架的限制,文件也被链接/寻找在前缀地址下: http://www.example.com/files/image.png (这是有效的和预期的) http://www.example.com/en/files/image.png http://www.example.com/ru/files/image.png 我想让我的nginx做的是按以下顺序尝试文件: $uri原样 /files/image.png (即使en或ru或任何其他双字母代码存在) /index.php文件生成,如果适用 1.和3.可以用简单的方式完成: location / { try_files $uri /index.php; } 我知道〜*命令告诉Nginx做一个正则expression式匹配( 源 )。 可悲的是,我不知道如何制定匹配来省略潜在的组,而不是select它。 并尝试与variables之前和之后让我尝试使用, if – 当然,我想避免这一点。 我相信我错过了一些相对简单的事情。
当我用ssl设置一个网站时,我几乎总是有这样的样板nginxconfiguration(注释说明): # Redirect both (http/https) non www. to www. server { listen 80; listen 443 ssl; ssl_certificate /etc/ssl/certs/www.example.com.pem; ssl_certificate_key /etc/ssl/private/www.example.com.key; server_name example.com; return 301 $scheme://www.example.com$request_uri; } # Redirect www. http traffic to www. https server { listen 80; server_name www.example.com; return 301 https://$host$request_uri; } # Serve www. website over https server { listen 443 ssl; […]
我试图在同一台服务器上有多个网站。 我有一个Debian和Nginx的DigitalOcean VPS。 无论我去site1.com,site2.com或site3.com,该网站显示site1.com的内容。 另外,当我inputwww.site.com,www.site2.com或www.site3.com Chrome浏览器显示“此网页不可用” 在… / sites-available /和… / sites-enabled /我拥有以下内容的site1.com,site2.com和site3.com文件。 这是从site1.com: server { listen 80; server_name site1.com www.site1.com; access_log /opt/www/site1.com/access.log; root /opt/www/site1.com; } 这是来自site2.com: server { listen 80; server_name site2.com www.site2.com; access_log /opt/www/site2.com/access.log; root /opt/www/site2.com; } 从site3.com: server { listen 80; server_name site3.com www.site3.com; access_log /opt/www/site3.com/access.log; root /opt/www/site3.com; } 我究竟做错了什么? 正如你所预料的那样,是的,这是我第一次设置一个Nginx服务器。 谢谢你的帮助!
我看到了proxy_cache_valid指令,但是让我困惑。 在HTTP中,上游服务器不是用Cache-Control和maxage ? 如何获得Nginx的caching来使用maxage ?