我有一个Django项目,我想用gunicorn(和apache proxing)交付它.我不能使用Nginx,所以这是不可能的.
我已经设置了Apache代理并为gunicorn设置了一个跑步者脚本,但我得到了这个奇怪的错误
2012-08-27 14:03:12 [34355] [DEBUG] GET /
2012-08-27 14:03:12 [34355] [ERROR] Error handling request
Traceback (most recent call last):
File "/home/tileone/venv/lib/python2.6/site-packages/gunicorn/workers/sync.py", line 93, in handle_request
self.address, self.cfg)
File "/home/tileone/venv/lib/python2.6/site-packages/gunicorn/http/wsgi.py", line 146, in create
path_info = path_info.split(script_name, 1)[1]
IndexError: list index out of range
Run Code Online (Sandbox Code Playgroud)
我正在运行这个脚本
#!/bin/bash
LOGFILE=/var/log/gunicorn/one-project.log
VENV_DIR=/path/to/venv/
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=5
# user/group to run as
USER=USER
GROUP=GROUP
BIND=127.0.0.1:9999
cd /path_to_project
echo 'Setup Enviroment'
#some libraries
echo 'Setup Venv'
source $VENV_DIR/bin/activate
export PYTHONPATH=$VENV_DIR/lib/python2.6/site-packages:$PYTHONPATH
#Setup Django Deploy
export DJANGO_DEPLOY_ENV=stage
echo …Run Code Online (Sandbox Code Playgroud) 我已经看过几个在Ruby中编写HTTP代理的例子,例如Torsten Becker的这个要点,但我如何扩展它以处理HTTPS,又称为"中间人"SSL代理?
我正在寻找一个简单的源代码框架,我可以扩展它以满足我自己的日志记录和测试需求.
我已经使用了Charles,一个类似于Fiddler 的漂亮的HTTPS代理应用程序,它本质上是我想要的,除了它在一个应用程序中打包.我想写自己的,因为我有过滤和演示的特定需求.
四处乱逛,我理解术语好一点.我不是在完整的"中间人"SSL代理之后.相反,它将在我的机器上本地运行,因此我可以尊重它提供的任何SSL证书.但是,我需要查看我的请求的数据包的解密内容和响应的解密内容.
public class FetchImageAppsActivity extends Activity {
/** Called when the activity is first created. */
public static String urlPath = "http://farm1.static.flickr.com/150/399390737_7a3d508730_b.jpg";
public ImageView imageView;
boolean usingProxy=true;
public String proxyIP="A.B.C.D";
public int proxyPort=80;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView =(ImageView) findViewById(R.id.imageViewFetch);
if(usingProxy==true){
setProxy();
}
try {
fetch(urlPath);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Drawable image = ImageOperations(this,urlPath,"overflow.png");
imageView.setImageDrawable(image);
/* imageView.setMinimumWidth();
imageView.setMinimumHeight(height);
imageView.setMaxWidth(width);
imageView.setMaxHeight(height);
*/
}
private Drawable ImageOperations(Context ctx, String url, …Run Code Online (Sandbox Code Playgroud) 我目前正在运行apache2一个SUSE实例@EC2.由于我的网站的一部分,我的数据使用mod_proxy打一个REST服务器上运行IIS通过Proxy/ReverseProxy.
在设置我的vhosts,启用mod_proxy并建立我的配置后,我发现我经常遇到502错误.这些错误是的Proxy Error和Bad Gateway风味.在做了一些相当可观的谷歌后,我发现方式有所不同IIS并apache终止了他们的连接,这导致了错误.设置以下环境变量后,性能显着提高:
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1 SetEnv
proxy-initial-not-pooled 1
我想知道为什么这是有效的,理想的配置是什么样的.
我的理解是,使用Env变量:
我强制一个HTTP 1.0 request(这将标准化终止预期)
不保持任何连接
不使用任何池化连接
正确吗?
如果我需要使用池化连接怎么办?如果我想使用keep-alives怎么办?简而言之,我正在寻找最佳实践来取代我目前正在使用的牙签和胶水解决方案
我有客户端:C,服务器:S(例如在端口7000上的本地ip 10.0.0.1上)和Web服务器:W(例如在www.example.com上)
C想通过Web路径联系S:http://www.example.com/path_for_server_S
所以W充当前向代理
现在S将通过相同的路径联系C:http://www.example.com/path_for_server_S
所以现在W充当反向代理
然后在Apache中,这将是一个常见的配置,如下所示:
ProxyPass /path_for_server_S http://10.0.0.1:7000
ProxyPassReverse /path_for_server_S http://10.0.0.1:7000
Run Code Online (Sandbox Code Playgroud)
已经有内置Web服务器的Play Framework可以处理这种情况吗?
搜索了很多,没事发现:)
我现在花了很多时间来配置我的代理.目前我使用的是名为proxybonanza的服务.他们为我提供了一个用于获取网页的代理.
我正在使用HTMLAGILITYPACK
现在,如果我在没有代理的情况下运行我的代码,那么在本地或上传到webhost服务器时没有问题.
如果我决定使用代理,它需要更长的时间,但它仍然在本地工作.
If I publish my solution to, to my webhost I get a SocketException (0x274c)
"A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host has
failed to respond 38.69.197.71:45623"
Run Code Online (Sandbox Code Playgroud)
我已经调试了很长时间了.
我的app.config有两个与此相关的条目
httpWebRequest useUnsafeHeaderParsing="true"
httpRuntime executionTimeout="180"
Run Code Online (Sandbox Code Playgroud)
这帮助我解决了几个问题.
现在这是我的C#代码.
HtmlWeb htmlweb = new HtmlWeb();
htmlweb.PreRequest = new HtmlAgilityPack.HtmlWeb.PreRequestHandler(OnPreRequest);
HtmlDocument htmldoc = htmlweb.Load(@"http://www.websitetofetch.com,
"IP", port, "username", "password");
//This is the preRequest config
static bool …Run Code Online (Sandbox Code Playgroud) 我在heroku上试图访问一个API,要求我的应用程序ip被列入白名单.所以,我使用heroku附加的proximo来获取api白名单的主机/ ip.
我设置为使用HTTParty测试连接的快速测试失败了.
class FakeRequest
include HTTParty
http_proxy 'XX.XXX.XX.XX', 80, 'user', 'pass'
def set_defaults
{:api_key=>"BLARG_BLARG",
:login_name=>"user",
:method => "do_something",
:response_format => "json",
:v => "1.0",
:login_password=>"pass"}
end
def make_post
HTTParty.post "https://test.com", :query => set_defaults
end
end
Run Code Online (Sandbox Code Playgroud)
这样:req = FakeRequest.new req.make_post
从api返回一条错误消息,抱怨源IP未列入白名单.我查看了源IP,它没有使用代理.如何使用代理而不是我的ISP的IP来发布HTTParty帖子.
我试图从URL下载一个zip文件,并使用java代码将其存储在本地系统中.我也使用系统代理.它无法连接到网址.任何的想法?
public static void main()
{
try
{
long startTime = System.currentTimeMillis();
System.out.println("Connecting to the url...\n");
System.setProperty("http.proxyHost", " http://abc.com");
System.setProperty("http.proxyPort","1111");
URL url = new URL("http://sourceforge.net/projects/sevenzip/files/7-Zip/9.20/7z920.exe/download?use_mirror=nchc");
url.openConnection();
InputStream reader = url.openStream();
FileOutputStream writer = new FileOutputStream("/home/user/result/apps.zip);
byte[] buffer = new byte[153600];
int totalBytesRead = 0;
int bytesRead = 0;
System.out.println("Reading ZIP file 150KB blocks at a time.\n");
while ((bytesRead = reader.read(buffer)) > 0)
{
writer.write(buffer, 0, bytesRead);
buffer = new byte[153600];
totalBytesRead += bytesRead;
}
long endTime = System.currentTimeMillis();
System.out.println("Done downloading. …Run Code Online (Sandbox Code Playgroud) 我的urlfetch客户端在部署到appspot时工作正常.但是通过代理的本地测试(dev_appserver.py)存在问题.我找不到任何方法来为urlfetch.Transport设置代理.
你如何在本地测试代理后面的urlfetch?
我正在设置webview,但我需要使用代理加载webview的内容.你们中的任何人都知道如何在NSURLRequest中实现代理?
例如:
NSString *location=@"http://google.com";
NSURL *url=[NSURL URLWithString:location];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
// some code to set the proxy
[self.myWebView loadRequest:request];
Run Code Online (Sandbox Code Playgroud)
我真的很感谢你的帮助