Articles of 重写

DNS和URL映射

我有在serverA.com/site上托pipe的内容,但是,当用户访问serverB.com/sitename时,我希望它加载serverA.com/site的内容(而url是在serverB上的sitll)。 这是可怕的,如果是这样,怎么样?

为什么nginx重写从/login/ /login发布请求?

有一个if语句,当客户端是Android的时候会重写url。 一切还好。 但是,有些奇怪的东西。 即使if语句的块是bank,Nginx也会将post请求/login写入//login。 所以我有一个404页面。 由于docker服务器只接受/login请求。 服务器conf: location / { proxy_pass http://localhost:8785/; proxy_set_header Host $http_host; proxy_set_header Remote-Addr $http_remote_addr; proxy_set_header X-Real-IP $remote_addr; if ( $http_user_agent ~ Android ){ # rewrite something, been commented } } debugging信息,原始日志https://gist.github.com/3799021 … 2012/09/28 16:29:49 [debug] 26416#0: *1 http script regex: "Android" 2012/09/28 16:29:49 [notice] 26416#0: *1 "Android" matches "Android/1.0", client: 106.187.97.22, […]

用nginx把基址重写为https

我想只有我的基地域名www.domain.com被重写为https://www.domain.com默认情况下,我的https地址块我重新路由到http://如果不是〜uri =“/” (基本域)或静态内容。 server { listen 443; set $ssltoggle 2; if ($uri ~ ^/(img|js|css|static)/) { set $ssltoggle 1; } if ($uri = '/') { set $ssltoggle 1; } if ($ssltoggle != 1) { rewrite ^(.*)$ http://$server_name$1 permanent; } } 所以在我的http块我需要做重写,如果它有https: server { listen 80; if ($uri = '/') { set $ssltoggle 1; } if ($ssltoggle […]

nginx:URL重写和性能

我有一个网站,我需要改变的url结构。 旧url看起来像/olddir/part1_de.htm ,新url看起来像/newdir/sub/category/anotherpage.htm 。 有很多我需要做的URL重写,最后我假设大概有500个不同的重写。 由于我的网站stream量很大,我主要关心的是目前的性能。 我的问题是: 我假设对于每个请求,重写块将被parsing,正则expression式将被评估。 我对吗? 如果我使用这些重写,会有性能损失吗? nginx能处理这个吗? 进行大量重写时,是否有任何“最佳实践”?

在IIS中向本地TomCat反向代理

IIS有几个网站: domain1.com a.domain2.com b.domain2.com 还有一个TomCat正在运行 localhost:8087 挑战是如何将TomCat外部公开为 b.domain2.com 我做了什么: 在IIS中的ARR中启用代理 在b.domain2.com上添加了反向代理URL重写规则 <rewrite> <rules> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="http://localhost:8087/{R:1}" /> </rule> </rules> <outboundRules> <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" > <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:8087/(.*)" /> <action type="Rewrite" value="http{R:1}://femiscan.a2itsolutionsllc.com/{R:2}" /> </rule> <preConditions> <preCondition name="ResponseIsHtml1"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> </outboundRules> </rewrite> 我所看到的: 如果我导航到本地 http://b.domain2.com […]

为什么nginx改变重写规则的HTTP方法?

每当我在mydomain.com上收到请求时,都会使用以下重写规则将其redirect到www子域: server_name mydomain.com; rewrite ^(.*)$ $scheme://www.mydomain.com$1 permanent; 但是,如果收到POST请求,它将被redirect为GET。 为什么? 什么是正确的方式来redirect呢?

如何在redirect上模拟Apache 标志?

出于商业原因,我为Apache 2.2.22(mod_rewrite)创build了以下重写规则: RewriteRule /site/(\d+)/([^/]+)\.html /site/$2/$1 [R=301,L] 如果给出了这样的url: http: //www.mydomain.com/site/ 0999 / document.html 被翻译成: http : //www.mydomain.com/site/ document / 0999 .html 这是预期的情况。 但是,有名称只是数字的文件。 所以考虑下面的情况: http://www.mydomain.com/site/ 0055/0666 .html 获取翻译成: http://www.mydomain.com/site/ 0666/0055 .html 这也符合我的重写规则模式,所以我最终浏览器的“网页导致了太多的redirect”错误。 我研究了很长时间,没有find“好”的解决scheme。 我试过的东西: 使用[END]标志。 不幸的是我的Apache版本不可用,也不适用于redirect。 在RewriteCond子句上使用%{ENV:REDIRECT_STATUS}来结束重写过程(L)。 出于某种原因,%{ENV:REDIRECT_STATUS}在我尝试的所有时间都是空的。 如果我的规则匹配,添加一个带有Header子句的响应头,然后检查这个头( 详情请看这里 )。 似乎a)REDIRECT_addHeader为空b)标题不能明确地设置在301响应上。 还有另一种select。 我可以设置一个查询参数的redirectURL,这表明它来自redirect,但我不喜欢这个解决scheme,因为它似乎hacky。 有没有一种方法可以完成[END]标志的function,但是在旧的Apache版本中呢? 比如我的2.2.22。 谢谢!

RewriteRule不正确重写url

我有以下虚拟主机文件: <IfModule !wsgi_module> LoadModule wsgi_module modules/mod_wsgi.so WSGISocketPrefix run/wsgi </IfModule> <VirtualHost *:80> RewriteEngine On RewriteLog "/var/log/httpd/rewrite_log" RewriteLogLevel 1 RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L] </VirtualHost> <VirtualHost *:443> ServerName https://tendril-api.dev.adnxs.net ServerAlias 06.tendril-api.dev.nym2.adnexus.net/api RewriteEngine on RewriteRule ^docs$ docs/ [R] … # SSL & WSGI Setup </VirtualHost> 出于某种原因,我的docs重写规则根本没有生效。 为什么是这样? 我的HTTP – > HTTPS重写规则在*:80 VirtualHost中正常工作。 我正在做一些非常相似的事情。 这是否与在不同的VirtualHosts中有两个不同的重写规则有关? 有任何想法吗?

如何使Nginx的子目录的文件path也包括index.php(Magento Multistore)

在Nginx服务器上使用Magento运行多重设置。 我正在看访问日志,可以清楚地看到发生了什么。 像许多PHPnetworking应用程序一样,它在它的URL中使用了index.php,并且设置为从可见的URL中“隐藏”它来保持它的清洁。 shoes.com/正在返回shoes.com/index.php shoes.com/sneakers正在返回shoes.com/sneakers/index.php 但是,如果我试图进一步,我看到Nginx不包括index.php的子目录,因为它是根目录。 注意:Magento基本上需要一个修改后的index.php来存放在子目录中的多重分区。 结帐示例: shoes.com/checkout/cart/返回shoes.com/index.php/checkout/cart/ 而在多目录目录中: shoes.com/sneakers/checkout/cart/正在返回shoes.com/sneakers/checkout/cart/,当它应该返回shoes.com/sneakers/index.php/checkout/cart/ 我想弄清楚如何让它适用于这个子目录index.php规则。 我有3个独立的文件我的Nginxconfiguration; 这是重写文件: rewrite_log on; location / { index index.php index.html; try_files $uri $uri/ @handler; } location @handler { rewrite / /index.php; } ## force www in the URL if ($host !~* ^www\.) { #rewrite / $scheme://www.$host$request_uri permanent; } ## Forward paths like /js/index.php/x.js […]

Nginx重写了一大堆URL到444

我正在寻找一个重写,将拿起任何数量的定义的url,并做任何返回444。 我没有单独写出每一个,而是希望能find一些我可以做的地方,如果location = defined file或者list,然后返回444。 我正在使用每个url的例子,这个工程。 我只想将wp-login.phpreplace成某种列表。 location = /wp-login.php { return 444; } 编辑:我试着做下面的东西,但不幸的是,没有工作 location = (/wp-login.php|/wp-admin.php) { return 444; } EDIT2: 谢谢泽维尔卢卡斯,这正是我所需要的。 我使用了你提到的,然后添加了一些它来添加更多不同格式的URL。 我们收到了大量的垃圾邮件怪异的URL,所以这很好。 location ~ ^(/wp-(admin|login)\.php|/url/path(.*)|/url2(.*)) { return 444; }