Articles of 重写

nginx proxy_pass将端口号添加到URL

我有一个标准的Rails应用程序部署到Heroku。 我正在使用自定义buildpack来安装nginx,所以我可以创build一些重写规则和反向代理。 除了一个问题我主要工作。 我有以下的location定义代理通过所有的url/博客/到另一个应用程序的URL。 location ~* ^/blog/?(.*) { set $forward_host 'another.app.com'; set $url_full '$1'; resolver 8.8.8.8 valid=300s; resolver_timeout 10s; # always add trailing slash rewrite ^([^.]*[^/])$ $1/ permanent; index index.html; proxy_hide_header Set-Cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme; proxy_set_header Host $forward_host; proxy_ignore_headers "Set-Cookie"; proxy_buffering off; proxy_intercept_errors on; proxy_redirect off; proxy_pass http://$forward_host/$url_full; } […]

将URL子域添加为HAProxy中的URLpath

我想转换下面的URL: http://subdomain.example.com/a/b/c 对此: http://example.com/subdomain/a/b/c 在HAProxy。 非常感谢

nginx – >使用基于cookie的try_files服务不同的文件(条件,如果,然后,其他)

我需要configuration一个nginx服务器,以便:如果用户有一个特定的cookie,所以服务器必须发送一个文件,否则服务器必须发送另一个。 我读了很多相关的文章,但没有什么帮助,也知道当try_files遇见的location if有一些问题,但如何解决这个问题… 我有一个例子,应该是有效的,但事实上并非如此: upstream site { server localhost:4321; } server { listen *:1234; server_name site.com; root /path/www/; ssl on; ssl_certificate /path/ssl.crt; ssl_certificate_key /path/ssl.key; location = / { set $variable /path/index.html; if ($http_cookie ~* "someCookie=someValue(?:;|$)") { set $index_file /path2/index.html; } rewrite .* $index_file break; try_files $uri/index.html $uri.html $uri @site; } }

redirect到HTTPS和子目录是可见的

我强制HTTPS和redirect到子目录: RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301] RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.domain.com$ RewriteRule (.*) /www_domain_com/$1 所有的工作,但http://www.domain.com 。 我在浏览器地址栏中看到: https://www.domain.com/www_domain_com/ : https://www.domain.com/www_domain_com/ 。 我的目标是从url中删除这个子目录,并在所有请求中都有ssl,并将所有请求redirect到该子目录。

在上菜之前先使用varnish检查html静态

我正在考虑编写一些逻辑到我的应用程序,以便它可以将静态页面内容写入s3或某个CDN,并主要从那里开始。 但是我不确定这是否可能。 例如,我有site.com/something,它应该首先在cdn中查找,如果不存在,则从varnishcaching或nginx / php-fpm提供服务。 这个想法是把stream量从服务器上拿走。 这是一个可能的情况? 在drupal中,我看到了一个模块来做到这一点 。 它将静态文件caching存储在磁盘中,并在其中存在。 下面是他们提供的图表。 他们问下面的.htaccess除外 # RewriteBase / ### BOOST START ### # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support) RewriteRule .* – [E=boostpath:normal] # Caching for anonymous users # Skip boost IF not get request OR uri […]

如何通过代理服务器上的SOAP我拥有(configuration)?

我有一个名为http://SERVER-A.com的服务器,它向第三方地址发送SOAP请求。 另外我有另一台服务器叫做http://Server-B.com ,我想configuration为代理服务器 。 我想通过服务器B (代理我的请求)将我的SOAP请求从A发送到第三方服务器。 我也想代理SOAP请求只有当请求被代理 (从A到第三方/不是直接请求B )。 我已经configuration我的服务器B htaccess文件如下: RewriteEngine On RewriteCond %{HTTP_FORWARDED} . RewriteRule ^ – [P] ProxyPassReverse / %{HTTP_FORWARDED} 我的configuration是否正确? 我应该怎么做呢? 我知道我应该在SOAP请求中configuration我的代理主机和端口。( php客户端)我只能访问.htaccess文件。 我只想让服务器B充当一个中间件(就像正在发送SOAP请求的B ) 谢谢你的帮助。

错误或错误的configuration重写nginx 1.8

我在/etc/nginx/conf.d/下有2个nginx的conf文件ssl.conf和default.conf 。 第一个文件处理传入的http请求。 它将http请求重写为https。 ssl.conf文件处理基于https的请求。 下面是, default.conf样子 server { listen 80 default_server; server_name abc.example.com 123-abc.example.com; port_in_redirect off; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; set_real_ip_from 127.0.0.1; set_real_ip_from 10.0.0.0/8; real_ip_header X-Forwarded-For; real_ip_recursive on; location /about { root /usr/share/nginx/html; add_header X-Frame-Options "DENY"; try_files $uri /about.html; } location /webapi { add_header X-Frame-Options "DENY"; } location / […]

IIS重写使用IISpipe理器

您好,我试图做一个适当的IIS重写利用我的托pipe服务提供商给我的IISpipe理器凭据。 我没有这方面的经验,到目前为止我在网上阅读的文章都没有太大的帮助。 这里是场景:我有一个ASP.net MVC 5网站( reallylongmaindomain.com ,为了便于阅读),物理上有file upload到它。 它使用SSL证书进行保护。 我们发布的文献有一个较短的域名(不是URL缩短的域名),我们称之为shortdomain.com ,它没有任何文件。 但是,如果您导航到shortdomain.com ,则会出现SSL域名不匹配错误(准确地说,ERR_CERT_COMMON_NAME_INVALID)。 这是我需要避免的。 在来的IIS经理。 我已成功login到系统并添加了URL重写。 这是我有的规则: (http(s)?://)?(www.)?shortdomain.com 。 这将处理用户可能放在地址栏中的任何http/https和/或www 。 操作属性设置为“redirect”(永久301),redirectURL设置为https://reallylongmaindomain.com ,但我仍然收到SSL证书错误,窗口中的URL仍然是shortdomain.com 。 我相信我只是错过了一两件简单的事情。 我是否也需要将规则添加到我的Web.Config文件中? 我以为IISpipe理器规则取代了Web.Config规则。 编辑 :规则被添加到我的web.config,这里是: <rewrite> <rules> <rule name="site redirect" stopProcessing="true"> <match url="(http(s)?://)?(www.)?shortdomain.com" /> <action type="Redirect" url="https://reallylongmaindomain.com" /> </rule> </rules> </rewrite> 谢谢!

Apache对iis重写规则

我正在尝试将Apache的网站移动到iis 8.5 一切正常,但1规则failes我的网站正常运行 RewriteCond %{REQUEST_URI} !\.(js|css|jpg|jpeg|gif|png)$ [or] RewriteCond %{REQUEST_URI} apple-touch-icon\.png$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L,QSA] 有人可以把它翻译成IIS重写? 我find了一些例子来做到这一点 <rule name="Webasyst Controller" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{URL}" pattern="!\.(eot|ttf|woff|js|css|jpg|jpeg|gif|png)$" negate="true" /> <add input="{URL}" pattern="apple-touch-icon\.png$" negate="true" /> </conditions> <action type="Rewrite" […]

Nginx的configuration位置正则expression式与语言代码在Url

尝试使用nginx正则expression式位置configuration实现url第一段中的常量语言代码,并找不到正确的语法。 必要的结果: example.com 保持 example.com example.com/zh 保持 example.com/en example.com/en/ 保持 example.com/zh 或 example.com/en/(不关心) example.com/en/etc 保留 example.com/en/etc example.com/etc 更改为 example.com/en/etc example.com/etc/segment 更改为 example.com/en/etc/segment 目前我已经发现了这个代码,但它仍然停留在某个地方。 它使永久循环,并不使用$ 1参数。 location ~ "^/(?![az]{2}/)(.+)$" { rewrite / /en/$1 permanent; } #Using handler here for removing index.php in uri (example.com/index.php -> example.com); location / { index index.htm index.html index.php; try_files $uri $uri/ […]