在 docker 设置中,对于不同的 Rails 环境,我们在和config.hosts中的指令方面遇到了不同的行为。development.rbproduction.rb
我们在同一台服务器上的同一个应用程序有两个 docker 镜像:“staging”和“Production”。它们同时在不同的容器和不同的端口上运行。
两个镜像都使用内部端口 3000 并向 docker 主机公开不同的端口(3002 和 3004)。
另一个虚拟机上的 apache 通过以下设置(在两个不同的虚拟主机中)将请求代理到容器:
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://192.168.99.102:3002/
ProxyPassReverse / http://192.168.99.102:3002/
ProxyPreserveHost Off
RequestHeader Set X-Forwarded-Ssl "On"
RequestHeader Set X-Forwarded-Port "443"
RequestHeader Set X-Forwarded-Host "dev.sitexxx.com"
RequestHeader set X_FORWARDED_PROTO "https"
</IfModule>
Run Code Online (Sandbox Code Playgroud)
对于开发环境和
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://192.168.99.102:3004/
ProxyPassReverse / http://192.168.99.102:3004/ …Run Code Online (Sandbox Code Playgroud) 我有一个使用CherryPy编写的Web应用程序,它在本地运行127.0.0.1:4321.我们使用mod-rewrite和mod-proxy让Apache充当反向代理; Apache还处理我们的SSL加密,最终可能用于传输所有静态内容.
这一切都适用于小型工作负载.但是,我最近urllib2编写了一个压力测试脚本,可以模拟100个客户端的工作负载.一段时间后,每个客户端从Apache获得503错误,表明Apache无法连接127.0.0.1:4321.CherryPy运行正常,但我的Apache错误日志显示如下行:
[Thu Oct 02 12:55:44 2008] [error] (OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : proxy: HTTP: attempt to connect to 127.0.0.1:4321 (*) failed
谷歌搜索此错误表明Apache可能已用完套接字文件描述符.由于我只运行了100个客户端,这意味着我的urllib2连接和Apache 之间的连接没有被关闭(我肯定是在调用.close()返回值urlopen),还是在Apache和CherryPy之间.
我已经确认我的urllib2请求是发送HTTP Connection: close标头,尽管KeepAlive On如果重要的话配置了Apache .
如果重要,我使用的是Python 2.5,Apache 2.2,CherryPy 3.0.3,并且服务器在Windows Server 2003上运行.
那么我的下一步是什么阻止这个问题呢?
我在同一台机器上同时拥有Apache 2和JBoss 4.2.3,并希望它们都使用80端口.有几种方法我看到人们在做这个mod_jk,mod_proxy,但我不确定哪一个是最好的.
我不需要任何负载平衡,但我确实需要HTTPS.
我使用mod_proxy(Apache2)监听127.0.0.1:80配置了一个反向代理,它将所有请求代理到127.0.0.1:8080
所以我已经配置了mod_proxy:
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /foo http://127.0.0.1:8080
ProxyPassReverse /foo http://127.0.0.1:8080
Run Code Online (Sandbox Code Playgroud)
当我请求时http://127.0.0.1/foo/bar,侦听127.0.0.1:8080的应用程序从mod_proxy获取以下请求URL:
相反,我想保留原始请求,并得到:
我怎样才能做到这一点?
我已经配置了一个Apache服务器,根据下面的配置为我们的Splunk安装提供SSO和反向代理.SSO与反向代理一样,隐藏在/ splunk URL后面的端口8000上运行的Splunk实例.
ProxyPass /splunk http://localhost:8000/splunk
ProxyPassReverse /splunk http://localhost:8000/splunk
<Location /splunk >
# Kerberos Authentication
AuthType Kerberos
AuthName "Kerberos Login"
KrbAuthRealms MYDOMAIN.COM
Krb5KeyTab /etc/krb5.http.keytab
KrbMethodNegotiate on
KrbAuthoritative on
KrbMethodK5Passwd off
KrbLocalUserMapping on
KrbSaveCredentials on
require valid-user
# SSO
RewriteEngine On
RewriteCond %{LA-U:REMOTE_USER} (.+)$
RewriteRule . - [E=RU:%1]
RequestHeader set REMOTE_USER %{RU}e
</Location>
Run Code Online (Sandbox Code Playgroud)
问题出在Apache日志中我收到了很多以下错误消息.
[client x.x.x.x] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' …Run Code Online (Sandbox Code Playgroud) 最近,我发现我的网站运行速度越来越慢。我发现我的服务器上有 8GB Apache 日志(我在 Debian 6 服务器上运行 Play!Framework Web 应用程序),并且带宽完全超载。对于一个每天浏览量很少的小型个人网站来说,这完全是疯狂的。
经过调查和收集一些信息后,我发现了我的错误:在我的 Apache 配置中,我取消了“ProxyRequests On”行的注释,因此我的服务器可以免费用作世界上每个人的免费代理。真丢脸。
至少在那段时间,我调整了防火墙以限制并发连接,并为 Apache2 安装了 mod_qos。
但是,现在所有传入请求都将重定向到我的 Web 应用程序,无论域名是什么,而不是像良好的免费代理那样将请求重定向到目的地。例如,如果有人使用我的服务器,认为它仍然是一个有效的代理,在雅虎上搜索“年轻的裸体儿童”,他就会访问我的网站。我想现在你明白我的意思了。
那么,如果将“ http://yahoo.com/whatever ”的请求发送到我的服务器,我应该怎么做,该请求就会被拒绝?
这是我当前的配置:
在/etc/init.d/apache2/sites-available/mysite.fr中:
ProxyRequests Off
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.fr
ServerAlias *.mysite.fr
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:9000/ retry=0
ProxyPassReverse / http://127.0.0.1:9000
# Uncomment the line below if your site uses SSL.
#SSLProxyEngine On
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)在/etc/init.d/apache2/mods-available/proxy.conf中:
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
Run Code Online (Sandbox Code Playgroud)我从nexus获取工件时遇到了麻烦,我希望社区可以帮助我.在nexus Web应用程序中访问和工作不是问题(我已将基本URL设置为https://www.fakesitename.com/nexus).
所有对https://www.fakesitename.com/nexus的呼叫都被重定向/转发/代理(正确的术语是什么?)到网络上的内部服务器
<VirtualHost *:443>
ServerName www.fakesitename.com
ServerAdmin webmaster@mysite.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /nexus http://192.168.0.178:8081/nexus
ProxyPassReverse /nexus http://192.168.0.178:8081/nexus
SSLEngine on
SSLCertificateFile /certs/mysite/ssl.crt
SSLCertificateKeyFile /certs/mysite/ssl.key
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
settings.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>public</id>
<mirrorOf>*</mirrorOf>
<url>https://www.fakesitename.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<!-- What should be in here?
<proxies>
<proxy> …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 Web 服务器上进行一些测试,以确保反向代理在将其放入实时环境之前按预期工作,但是我遇到了 mod_proxy 和 mod_proxy_html 的一些问题。
我有 2 个虚拟主机,1 个在端口 80 上,1 个在端口 8080 上。我的目标是让 www.example.com/path/ 的传入请求进入端口 80,并反向代理到端口 8080。
这是我的虚拟主机设置:
<VirtualHost *:8080>
ServerName www.example.com:8080
DocumentRoot /var/www/html/test
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*test
RewriteRule ^/?(.*) http://127.0.0.1:8080/test.html [R=301,L]
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
ProxyHTMLEnable On
ProxyHTMLInterp On
ProxyPreserveHost Off
ProxyPass /path/ http://127.0.0.1:8080/
ProxyPassReverse /path/ http://127.0.0.1:8080/
ProxyHTMLURLMap http://127.0.0.1:8080/ /path/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我的 /var/www/html/test 有 2 个文件 index.html 和 test.html
test.html 内容是:
<HTML>
<BODY>
<a href="http://127.0.0.1:8080/index.html">TEST</a>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
转到 www.example.com/path/ 成功被代理并重定向到 www.example.com/path/test.html,但页面上的链接仍指向 127.0.0.1。
httpd -M …
最近我需要将 websocket 服务器与 apache2\xef\xbc\x8can 集成,我发现 apache2.4 已支持带有以下模块的 websocket:mod_proxy_wstunnel.\n http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
我自己编译了它们,但遇到了问题:
\n\nhttpd: Syntax error on line 122 of /usr/local/apache2/conf/httpd.conf: Cannot load modules/mod_proxy_wstunnel.so into server: /usr/local/apache2/modules/mod_proxy_wstunnel.so: undefined symbol: ap_proxy_release_connection
我的步骤是:
\n\n我需要将路径映射到我的 tomcat Web 应用程序。我为此使用了代理通行证。这是 apache2 中的当前配置
<VirtualHost *:80>
ServerName localhost:80
ProxyPass /app http://localhost:8088/ui/
ProxyPassReverse /app http://localhost:8088/ui/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
这从 tomcat 获取 HTML,但形成的 css url 是错误的。而不是http://localhost/app/css/style.cssurl 被映射为http://localhost/ui/css/style.css.
我尝试使用重写,但没有用。
RewriteEngine on
RewriteRule ^/ui/ /app/
Run Code Online (Sandbox Code Playgroud)
我需要找到更正 URL 的正确方法。任何帮助将不胜感激!提前致谢。