我试图设置Nginx使用proxy_pass转发请求到几个后端服务。 其中一些不支持在子文件夹下访问,所以我必须添加一个重写来剥离附加的子文件夹,以允许从同一端口访问它们。 有关改进重写的任何提示? curl输出; :~$ curl -I -k https://example.net/internal HTTP/1.1 404 Not Found Server: nginx/1.0.5 Date: Thu, 19 Jan 2012 22:30:46 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive Content-Length: 145 :~$ curl -I -k https://example.net/internal/ HTTP/1.1 200 OK Server: nginx/1.0.5 Date: Thu, 19 Jan 2012 22:31:12 GMT Content-Type: text/html Connection: keep-alive Content-Length: 1285 Accept-Ranges: bytes Last-Modified: […]
如何从参数中删除一个url的.html? 例如: http : //www.domain.com/somepage.html?argument= whole& bunch=a-lot 至: http://www.domain.com/somepage?argument=whole&bunch=a-lot 我努力了 location / { index index.html index.php; rewrite ^\.html(.*)$ $1 last; try_files $uri $uri/ @handler; expires 30d; ## Assume all files are cachable } 和一堆其他的build议,但似乎无法使其工作…. TNX
我正在尝试重写以我的网站为目标的url,以便将所有网域名称重写为www.example.com并具有以下configuration: mysite块 server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name _; rewrite ^ $scheme://www.example.com$request_uri permanent; location / { # Allow for large file uploads client_max_body_size 0; proxy_http_version 1.1; proxy_pass http://mysite; proxy_buffering off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } } tomcat服务器块 server { listen 80; root /opt/site2/www; […]
我有一个Web应用程序安装(ClockingIT),基于使用的子域名。 因为我们想要使用SSL并且没有通配符证书,所以这对我们来说不是很方便:-)所以我想到了使用Apache的mod_proxy和mod_rewritefunction。 更确切地说,我希望URL Xttps://example.com/cit/(external)显示Xttp://test.example.com:3000 /(内部)的内容。 这是我的设置: <VirtualHost *:443> ServerName example.com (SSL setup, etc) SSLProxyEngine On UseCanonicalName Off ProxyRequests Off ProxyPreserveHost Off # or On, makes no difference RewriteEngine On RewriteRule ^/cit$ Xttp://test.example.com:3000/ [P,NC] RewriteRule ^/cit/(.*)$ Xttp://test.example.com:3000/$1 [P,NC] ProxyPassReverse /cit/ Xttp://test.example.com:3000/ test.example.com未在DNS服务器上定义,但在/ etc / hosts中设置为映射到127.0.0.1。 如果我在服务器上执行“w3m Xttp://test.example.com:3000 /”,我会得到正确的网页。 但是,如果我在桌面浏览器上访问https://example.com/cit/ ,则无法获得正确的网页。 networking应用程序收到请求,但似乎认为请求是为example.com域,并提供默认页面,而不是预期的子域“testing”的内容。 似乎不知何故代理不传递test.example.com域,虽然根据文档它应该。 而不是RewriteRule,我也尝试了ProxyPass指令,但结果相同。 有什么我失踪? (如果相关,ClockingIT是通过Mongrel服务的Ruby on […]
我已经运行了YOURLS服务器来为我的公司提供简短的URL,以便我们可以向客户提供简短的URL。 我使用nginx,并为域的根,如果他们不使用适当的短url我想redirect到我们的网站。 因此,example.com/218aredirect到任何简短的url指向,但example.com去我们的网站@ domain.com。 现在,我正在使用一个index.html页面,只是一个元刷新redirect,但我想我应该能够在nginxconfiguration中做到这一点,它可能会更好。 有人可以帮助我,如果可能的话,在服务器级而不是使用元刷新发生? 我已经尝试了一些我在这里find的例子,但是没有一个能够工作。 这是我的configuration文件供参考。 server { server_name www.domain.com; return 301 $scheme://domain.com$request_uri; } server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name http://domain.com; location / { #YOURLS try_files $uri $uri/ /yourls-loader.php; } location ~ \.php$ { try_files $uri =404; […]
正如你所知,亚马逊EC2实例得到的地址如下所示: ec2-72-44-40-153.z-2.compute-1.amazonaws.com 如果我有域名example.com,有没有什么办法可以使bob.example.com或最好example.com/bobredirect到IP ec2-72-44-40-153.z-2.compute-1.amazonaws.com ?? 谢谢!!
我知道这一定是已经回答了,但是我一直在寻找一段时间,找不到答案。 只是不在正确的地方,我想,也许有人可以帮助我。 基本上我通过SSL在非标准端口上运行phpmyadmin,在这个例子中是12345。 现在我有https://example.com:12345设置好了,它的工作原理和一切。 现在我想添加inputhttp://example.com:12345并redirect到https://的function。 我假设以下将工作,但事实并非如此。 server { listen 12345; server_name php.myadmin.com; if ( $scheme = http ) { rewrite ^ https://php.myadmin.com:12345$request_uri? redirect; } root /var/www/php; ssl on; [….] } 这给了我一个400 bad request 。 现在,在发布答案之前,请务必仔细阅读redirect表单。 检查链接下面的陷阱。 https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#taxing-rewrites 此外,如果甚至可以在没有if语句的情况下完成这将是很好的: https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#using-if
某些应用程序(如Plone)默认为在80以外的端口上提供http(例如8080)。 通常,要查看这些webapps,您需要加载http://mysite.tld:8080而不是http://mysite.tld (假设您也有一个运行在端口80上的“标准”网站)。 有没有办法将地址栏中显示的端口号伪装和/或隐藏,以便访问者不知道它们不在标准的http端口上? 如果是这样,怎么样? URL是否被重写为正确的方法?
我有两个域www.domain.com和www.domain.com.tw。 我希望用户被redirect到最近的服务器,但是如果他们想要查看另一台服务器,他们可以通过点击站点中的链接。 我试图用cookie来做,但似乎没有工作。 我认为问题在于cookie是为引用URL设置的,而不是redirect的URL,所以nginx甚至不会看到cookie。 我怎样才能做到这一点? 这是我迄今的尝试。 server { listen 80; server_name www.domain.com.tw; set $redir ""; if ($http_accept_language ~* "en") { set $redir "1"; } if ($http_cookie ~* "noredir") { set $redir ""; } if ($redir = "1") { rewrite ^ https://www.domain.com/; } }
我使用前端控制器和以下htaccess文件pipe理大量的PHP应用程序: FallbackResource /index.php 是的,这是整个文件(每个应用程序)! 但是,有些网站位于子文件夹中,因此需要进行以下更改: FallbackResource /subfolder/index.php 正如你可能猜到的那样, /开头意味着path相对于站点/虚拟主机,这里的path需要相对于目录。 (如果我使用的是mod_rewrite而不是mod_dir ,则需要按照类似的方式将RewriteBase添加到每个子目录中。) 我认为我可以通过这样做来解决这个问题: FallbackResource index.php # No slash! 但是,当站点的重写包含斜线时,例如,如果应用程序是/store/并且其中的path是products/1234 ,则Apache将查找/store/products/index.php而不是/store/index.php然后在日志中返回一个500与以下消息: 由于可能的configuration错误,请求超过了10个子请求嵌套级别的限制。 如果需要,使用“LimitInternalRecursion”来增加限制。 使用“LogLeveldebugging”来获得回溯。 我会认为FallbackResourcepath是相对于它configuration的.htaccess文件,但它似乎实际上是相对于请求的URL。 有没有办法使FallbackResource按照我的预期行事? 如果这是答案,我可以用它的方式,但如果能做到这一点,pipe理我所拥有的网站会容易得多。 这些网站使用相同的基本代码,不同的主题和数据库连接,现在它的工作方式,现在我必须修改htaccess文件,每次部署新版本的代码(因为它被检查到Git)。 如果我们能够让人们不必每次都记住这个修改,那真是太棒了。