Articles of 重写

nginx proxy_pass根据位置/传递rewritedurl的不同后端

如果你想通过基于位置的proxypass代理URL请求到两个不同的后端,最快和最干净的解决scheme是什么。 location /app1/ { alias /var/www/ruby/public; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; try_files $uri $uri/ @ruby; } location @ruby { proxy_pass http://127.0.0.1:3000; } location /app2/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; try_files $uri $uri/ @other; } location @other { proxy_pass http://127.0.0.1:8080; } 有了这个configuration,nginx将"/app1"或“ /app2 […]

Nginx的所有子域指向一个子域(gitlab)规则

我已经在我的服务器上安装了gitlab,并使用nginx作为http服务器…我简单地在nginx上使用gitlab的配方 # GITLAB # Maintainer: @randx # App Version: 3.0 upstream gitlab { server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; } server { listen 192.168.250.81:80; # eg, listen 192.168.1.1:80; server_name gitlab.xxx.com; # eg, server_name source.example.com; root /home/gitlab/gitlab/public; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { # serve static files from defined root folder;. […]

如何将apacheconfiguration为查询string参数中指定的远程服务器的反向代理

问题: 我试图configurationapache作为一个反向代理,其中在查询string参数中指定删除服务器。 假设我正在mywebapp.com上提供一个站点。 如果你导航到http://mywebapp.com/proxy?url=http://www.someothersite.com ,那么Apache应该作为反向代理http://www.someothersite.com 。 同样,如果您导航到http://mywebapp.com/proxy?url=https://login.notmysite.com ,那么apache应该作为https://login.notmysite.com的反向代理。 注意事项: 1.在响应html中重写相关url以通过代理 2.重写来自远程服务器的redirect响应。 例如,如果用户请求mywebapp.com/proxy?url= https://login.notmysite.com ,并且远程服务器以https://login.notmysite.com/redirect,则用户的浏览器应该会看到redirect到mywebapp.com/proxy?url= https://login.notmysite.com/ 。 3.支持http和https 4.支持cookies 5.合理的安全。 我不想为世界上的任何人打开一个代理服务器,只能在mywebapp.com网站上的iframe中使用。 环境: 我使用Apache 2.2.24,但我可以升级,如果这将使问题更容易解决。 当前configuration: <VirtualHost 127.0.0.1:8081> ServerName www.mywebapp.com SSLProxyEngine On RewriteEngine on RewriteCond %{QUERY_STRING} ^url=(.*)$ RewriteRule ^/proxy – [E=url:%1] RewriteCond %{QUERY_STRING} ^url=(https?://[^:/]+)/? RewriteRule ^/proxy – [E=url_host:%1] RewriteCond %{QUERY_STRING} ^url=(.*)$ RewriteRule ^/proxy %1 [P] ProxyPassInterpolateEnv On […]

nginx / php + zurmo,重写或内部redirect周期

我试图让本地主机上的Debian Jessie系统上运行的Zurmo CRM。 我无法find一个例子nginxconfiguration和应用程序需要重写URLS,我做错了。 我也使用重写在Drupal,我认为这是Nginxconfiguration将工作,但没有运气。 server { server_name zurmo; listen 80; root /var/www/sites/zurmo; index index.php; location = / { root /var/www/sites/zurmo; index index.php; } location / { root /var/www/sites/zurmo; index index.php; if (!-f $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } if (!-d $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } } location ~ ^/(protected|framework|themes/\w+/views) […]

URL重写对于magento不起作用

Web服务器重写在admin中设置为yes。 安全和不安全的url没有index.php。 mod-rewrite被启用并且工作 我尝试所有与RewriteBase /在htaccess的组合 更多的时间冲刷现金比我可以数(这与mod_rewrite没有任何关系,但我仍然这样做) 重新编制目录的URL重写(同上)[/ b] 但它不工作:( http://162.13.86.217/~useraccount/url.html The requested URL /home/useraccount/domains/mydomain.com/public_html/index.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. BUt index.php确实存在,它位于:/home/useraccount/domains/mydomain.com/public_html/ 我有从magento默认的htaccess文件的地方,它适用于其他服务器上完美: ############################################ ## rewrite everything else to index.php RewriteRule ^(.*)$ index.php [L]

奇怪的nginxconfiguration:多个重写规则不起作用

我有一个应用程序知道如何准备一些特殊的图像,并在另一台机器上运行(我试图把它用作图像服务器)。 当这些图像由应用程序准备并提供时,也可以通过一种可公开访问的path(如/image/files/medium/562.jpg)进行精确保存,以防止在进一步的请求中一次又一次地运行应用程序。 我的应用程序实现了前端控制器模式,所以我需要发送请求到我的应用程序/thumbnail/process/?qs=1&qs=2不是/thumbnail.php或类似的东西。 另外我需要从最终用户掩盖我真正的缩略图处理器url。 此时stream程如下: 最终用户发出图片请求,如/picture/small/518.jpg Nginx捕获它,并重写为/image/files/small/518.jpg因为实际上没有picture文件夹。 如果/image/files/small/518.jpg存在,nginx应该直接服务它,而不是传递请求到应用程序。 如果它不是(图像不存在),nginx必须重新(或redirect),并通过自定义URI请求传递给应用程序/thumbnail/process/?size=small&model=866 另外ngnix不应该接受其他请求,如果它不是一个图像请求,并应立即返回444。 所以,我试图通过为nginx编写自定义规则来解决这些问题,但不起作用。 已经处理的图像没有问题,但是它的生成404没有find响应,而不是将请求传递给应用程序。 我找不到这个configuration有什么问题,我错过了什么。 server { listen 127.0.0.1:80; server_name image.mydomain.com; root /var/www/public_html; location / { # I know if is evil. # Don't pass request to the application if it's not a image request! if ( $uri !~ ^/(image|picture|thumbnail)/(.*)$ ) { return 444; } } # […]

Nginxredirect到URL中指定的端口

是否有可能使用Nginx从这样的URL代理: http://example.com/service/1234/foo.php?… 到像这样的内部服务: http://example.com:1234/foo.php?… 也就是说,从URL中提取一个数字,并将其作为端口号使用到同一台服务器上? rewrite似乎仅限于操作端口后的URL部分,我不认为proxy_pass可以从中访问正则expression式的子string。 我试图解决的具体问题是,我的服务都可以在端口80上访问,因为各种公司和公共networking阻塞了实际运行服务的异国情调的端口。 所以它必须是一个反向代理,而不是一个redirect。 此方法适用于单个端口: location /service/5010 { rewrite ^/service/5010/(.*)$ /$1 break; proxy_pass http://127.0.0.1:5010; } 但问题是如何使5010只是从URL中提取的参数。

任何URL重写规则导致iis7上的内部服务器错误

我有一台Windows Server 2008上的iis7,并安装了iis url重写模块2。 任何URL重写规则(在我的情况下,一个简单的规范域名规则)导致webapp返回错误500。 在我的情况下,我有4个域映射到相同的Web应用程序,并希望将其他域的3redirect到主域,设置规则后,对这些域的Web应用程序的任何请求返回错误,Web应用程序的一个域那不受规则影响仍然没有问题。 我修复了iisurl重写模块,但问题仍然存在。 如果我closures自定义错误,我看到问题是在我的networking应用程序,但是如果没有任何重写/redirect规则,我不会收到任何错误。 可能重写正在搞乱pipe道中的某些东西。 堆栈跟踪如下: [NullReferenceException: Object reference not set to an instance of an object.] Glimpse.Core.Extensions.DataStoreExtensions.Get(IDataStore store, String key) +35 Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +50 Castle.DynamicProxy.AbstractInvocation.Proceed() +595 Castle.Proxies.IDependencyResolverProxy.GetService(Type serviceType) +177 System.Web.Mvc.DependencyResolverExtensions.GetService(IDependencyResolver resolver) +61 xxxxx.NHibernateSessionPerRequestModule.<Init>b__1(Object param0, EventArgs param1) +40 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165 url不应该重写/redirect结束请求的处理并提交响应?

俘虏门户/围墙花园popup窗口上的android不出现

我通常不会寻求帮助,但是我已经坚持了几天 – 任何人都可能有的指针将非常感激。 我创build了一个WiFi热点(强制门户/围墙花园) – 使用Windows Server 2012,Unbound DNS和Apple Extreme路由器。 我有IIS运行使用URL重写的照顾redirect,所有的iOS设备都很好。 我试图让android设备在joinwifinetworking时显示popup的CNA窗口。 我在我的web.config中通过这个规则来做这件事 <rule name="android rule" enabled="true" stopProcessing="false"> <match url="(.*)generate_204(.*)" /> <!– <action type="Redirect" url="http://supplierfinder.ubm-com.net/WebPage.cshtml" appendQueryString="false" redirectType="Temporary" /> –> <action type="Rewrite" url="WebPage.cshtml" appendQueryString="false" /> </rule> 我确信这个redirect正在工作,并在设备连接到networking时提供页面。 这是一个日志条目 2015-09-05 19:06:48 W3SVC2 WIN-8CHVURO21ID 10.0.1.2 GET / generate_204 – 80 – 10.0.1.12 HTTP / 1.1 Dalvik / 1.6.0 […]

Apache RewriteRule 502在开发服务器上的错误,在现场工作

我在Apache 2.2.15上。 我的vhost.conf包含一个RewriteRule来处理文章的URL; # handling for neat article titles RewriteRule ^/news/[0-9]{4}/[A-za-z]{3}/([0-9a-zA-Z-]*)/([0-9]{4})([0-9]{6})/?$ "/news/article.cfm?clk=$2&article_id=$3&urltitle=$1" [P,L] 这是在我们的活服务器上正常工作,但是在我的本地开发服务器上,当我尝试加载文章时,浏览器中出现502错误: Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /news/2015/news-article/0123012345. Reason: DNS lookup failure for: localhost.example.com Apache/2.2.15 (CentOS) Server at localhost.example.com Port 80 这是我在错误日志中得到的; [Wed Oct 28 10:00:25 […]