开发者

php proxy to local mercurial server

开发者 https://www.devze.com 2022-12-24 04:00 出处:网络
I was wondering is it possible to create a php proxy to a server that listens onlu locally so that the php gateway is public and it directs everything to the server listening on localhost.

I was wondering is it possible to create a php proxy to a server that listens onlu locally so that the php gateway is public and it directs everything to the server listening on localhost.

This server would be mercurial's hg serve that listens only on 127.0.0.1 and php will do the authentication.

Do You think it's possible to do? Anybody has an idea how to make a ge开发者_JS百科neral proxy in php so that not only http get works, but also hg push?

I know there are ways to host mercurial repo with auth, but it's on a plug computer and I don't have a lot of space for more apps etc.


You don’t need to run hg serve.

Instead, use hgweb.cgi or hgwebdir.cgi. These are standard CGI scripts that can be run under Apache. hgweb.cgi serves a single repository, and hgwebdir.cgi serves multiple repositories. They do not require any special modules to be installed on Apache, and you can use all of Apache’s built-in access-control and authentication mechanisms.

The best reference is PublishingRepositories on the Mercurial wiki, which explains how to do this and also compares other options, including ssh, which requires even less setup.


If you really want to use PHP, you could use the socket functionalities to do whatever networking you want. (http://ch.php.net/manual/en/ref.sockets.php) And you can use fsockopen to connect to whatever you want. You could combine this and use it in a PHP script which you run by console. Use set_time_limit repeatedly to keep your proxy running. You'll need a lot of knowledge and luck to get this done.

But actually it's really WEIRD what you're doing (see other answers and comments). Whatever reason you have for this configuration, it's wrong.


If you're running your php in apache, then you can probably do what you want with php. Just configure apache to proxy to hgserve (assuming you can't run wsgi or cgi, which is the better solution) and you're set. I don't think there's anything to add in PHP land that apache and hgserve don't already bring to the table.

But, yes, you could reimplemnt Apache's proxy functionality in PHP, though you'll also need to make sure to include support for RangeRequests, which mercurial uses in some situations. Don't forget your RFC2616 caching logic (If- headers, Cache-Control, Expires, Last-Modified, etc.) for efficiency...

0

精彩评论

暂无评论...
验证码 换一张
取 消