在阻塞 80 端口的网络上创建舞台环境

发布于 2024-07-07 19:59:52 字数 416 浏览 8 评论 0原文

我目前使用本地 Web 服务器来允许客户预览一些应用程序,并允许下载我的开源库的“夜间版本”。

问题是我更换了 ISP,现在我的 80 端口被阻止了。

尽管我知道我可以轻松更改 Apache 服务器上的端口,但我想避免这种情况,除非别无选择。

您是否知道任何第三方服务(免费或付费)可以将端口转发到我的网站,使其对访问该网站的人透明?

我听说的另一个想法是使用我当前的网络主机的 mod 重写来重写我的域,但我也不想走这条路。 除此之外,您知道任何实际有效的 .htaccess 示例吗? 我已经尝试过这个:

RewriteEngine on
RewriteRule ^/(.*) http://www.example.com:8080/$1

但它似乎不起作用。

I currently use my local web server to allow costumers to preview some applications and also to allow downloads of "nightly builds" of my open source library.

Problem is I changed my ISP and now my port 80 is blocked.

Altough I know I could easily change the port on the Apache server, I'd like to avoid that unless there's no alternative.

Do you know any third party service (free or paid) that would do a port forward to my website, making it transparent to someone accessing it?

One other idea I heard about was using mod rewrite from my current webhost to rewrite to my domain, but I'd also prefer not go this path. Besides that, do you know any .htaccess examples that actually work? I have tried this:

RewriteEngine on
RewriteRule ^/(.*) http://www.example.com:8080/$1

But it doesn't seem to be working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

终遇你 2024-07-14 19:59:52

“并以透明的方式再次返回给客户”...将由 NAT 处理,因此这应该不是问题。

要处理从一个字符串到另一个字符串的请求转换,这是一个问题,因为您需要在请求到达服务器之前对其进行转换。 研究某种 URL 转发服务

http://www.dnsexit.com/Direct。 sv?cmd=webforward

您还可以在提供商服务器上设置一个单独的站点,并将请求转发到您服务器上的特定地址/链接。

希望这可以帮助!

"and back again to the costumer on a transparent way"....will be taken care of by NAT so that shouldn't be a problem.

To handle the request translation from one string to another, well that's an issue since you need to transform the request before it hits the server. Look into some kind of URL forwarding service

http://www.dnsexit.com/Direct.sv?cmd=webforward

Also you can setup a separate site on a provider server and have it forward requests to the specific address/link on your server.

Hope this helps!

顾忌 2024-07-14 19:59:52

我希望客户能够
类型
http://myaddress.com/hello/there?a=1&b= 2
它被翻译成
http://mylocalserver.com:8080/hello/there?a= 1&b=2
然后再次返回给客户
透明的方式。

我相信这就是您正在寻找的用于重定向任何 URL 的 Apache RewriteRule:

RewriteRule ^(.*)$ http://mylocalserver.com:8080$1 [R]

从那时起,客户将浏览 mylocalserver.com:8080,这就是他们将在地址栏中看到的内容。 如果您所说的“然后再回来”的意思是他们仍然认为自己正在浏览 myaddress.com,那么您所说的是重写代理服务器。

我的意思是,您不仅必须重写 HTTP 标头中的所有 URL,还必须重写 HTML 内容中的所有 URL(即在 HTML 上执行正则表达式搜索/替换),并解码、重写和重新发送所有 GET、POST、PUT 数据, 也。 我曾经写过这样一个代理,让我告诉你这不是一个简单的练习,尽管原理可能看起来很简单。

我想说,如果您能让重定向正常工作并让他们从那时起浏览 mylocalserver.com:8080,那就很高兴了。

What I'd like is for the costumer to
type
http://myaddress.com/hello/there?a=1&b=2
and it get translated to
http://mylocalserver.com:8080/hello/there?a=1&b=2
and back again to the costumer on a
transparent way.

I believe this is the Apache RewriteRule you're looking for to redirect any URL:

RewriteRule ^(.*)$ http://mylocalserver.com:8080$1 [R]

From then on the customer will be browsing mylocalserver.com:8080 and that's what they'll see in the address bar. If what you mean by "and back again" is that they still think they're browsing myaddress.com, then what you're talking about is a rewriting proxy server.

By this, I mean you would have to rewrite all URLs not only in HTTP headers but in your HTML content as well (i.e. do a regex search/replace on the HTML), and decode, rewrite and resend all GET, POST, PUT data, too. I once wrote such a proxy, and let me tell you it's not a trivial exercise, although the principle may seem simple.

I would say, just be happy if you can get the redirect to work and let them browse mylocalserver.com:8080 from that point on.

暗恋未遂 2024-07-14 19:59:52

由于端口 80 被阻止,通过动态服务进行路由将无济于事,除非客户端在域中指定新端口。

让本地路由器将流量从新端口(例如 8080)“端口转发”到端口 80。让一切保持不变。

使用 DynDNS.org 创建帐户并设置您的动态服务。 然后让你的客户做 http://mydomain.com:8080

这应该可以解决问题

仍然看看 Rolf 的建议因为他们不是真正的 ISP,....说真的。

谢谢

With port 80 being blocked, routing through Dynamic Service win't help, unless the client specifies the new port in the domain.

Have your local router "port-forward" traffic from a new port (say 8080) to port 80. Leave everything the same on your end.

Create an account with DynDNS.org and set up your dynamic service. Then have your client do http://mydomain.com:8080

That should do the trick

Still look into Rolf's suggestion as they are not real ISP,....seriously.

Thanks

鹿童谣 2024-07-14 19:59:52

如果您无法让 ISP 为您打开端口 80,并且您无法切换 ISP,请使用 htacccess 重定向指令:

Redirect 301 / http://yourserver.com:8000/

用户可能会注意到重定向,但他们可能不会关心。

If you can't get your ISP to open up port 80 for you, and you can't switch ISPs, then use the htacccess redirect directive:

Redirect 301 / http://yourserver.com:8000/

The users may notice the redirect, but they probably won't care.

孤者何惧 2024-07-14 19:59:52

好吧,尽管我很欣赏这些答案,但我对最终结果不太满意。 我希望我的 ISP 更改对我的客户来说是透明的,并且我想我设法让它发挥作用。

这就是我所做的:

我租了一台便宜的 VPS 服务器 - VPSLink - 并选择了最便宜的套餐:64Mb RAM、2Gb HD以及每月 1Gb 的流量。 终生 10% 折扣后,每月只需 7.16 美元,对于这份工作来说相当实惠,而且您还可以获得沙盒 VPS 服务器作为奖励。 到目前为止,托管看起来还不错——没有问题。 如果您想尝试一下,您可以从其网站(如上所示)注册或通过推荐代码注册。 网上有很多,你只要搜索一下就可以了。 另外,如果您愿意,我可以轻松地为您创建一个,只需对此答案发表评论即可:您将获得 10% 的折扣,而我将免费获得一个月。 我不会直接在这里发布,因为这似乎是这篇文章背后的意图 - 但事实并非如此。

该帐户不受管理,但提供 root 访问权限。 然后,我将 apache 配置为充当端口 80 请求的代理,透明地将它们转发到端口 8081 上的本地网站。

下面是我的 Apache 的 httpd.conf 配置文件的一些片段。

VPS 服务器配置:

<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com *.mydomain.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} (.*)\.mydomain\.com [NC]
    RewriteRule (.*) http://mylocalserverdns.mydomain.com:8081/%1$1 [P]
</VirtualHost>

这会发出类似 http://subdomain1.mydomain 的请求.com/script?a=b 在服务器端透明转发到 http://mylocalserverdns.mydomain.com:8081/subdomain1/script?a=b,这样我就可以从那里做任何我想做的事情。

在我的本地服务器上,我做了同样的事情来分发我的子域处理程序。 例如,我有两个 Java 服务器应用程序,在本地端口 8088 和 8089 上运行。 我所要做的就是另一个代理转发,现在在内部

本地服务器配置:

<VirtualHost *:8081>
    ServerName mylocalserverdns.mydomain.com

    ProxyPass /app1 http://127.0.0.1:8088
    ProxyPassReverse /app1 http://127.0.0.1:8088
    ProxyPassReverse /app1 http://mylocalserverdns.mydomain.com:8088/app1

    ProxyPass /app2 http://127.0.0.1:8089
    ProxyPassReverse /app2 http://127.0.0.1:8089
    ProxyPassReverse /app2 http://mylocalserverdns.mydomain.com:8089/app2
</VirtualHost>

希望如果其他人正在寻找相同的替代方案,这是值得的。

Well, even though I appreciated the answers, I wasn't quite satisfied with the final result. I wanted my ISP changes to be transparent to my costumers and I think I managed to make it work.

Here's what I did:

I hired a cheap VPS server - VPSLink - and chose its cheapest plan: 64Mb RAM, 2Gb HD and 1Gb monthly traffic. After a lifetime 10% discount it was only US$ 7.16 per month, pretty affordable for the job and you get a sandbox VPS server as a bonus. The hosting seems so far so good - no problems. If you want to give it a shot you can either signup from its site, indicated above or through a referral code. There are a bunch available on the internet, you just need to search. Also, I can easily create one for you if you want, just leave a comment on this answer: you'll get 10% off and I a month free. I won't post the directly here because it may seem that was the intention behind this post - which was not.

This account is unmanaged but it provides root access. I then configured apache to act as a Proxy to my port 80 requests, transparently forwarding them to my local website on port 8081.

Below are some snippets of my Apache's httpd.conf config files.

VPS Server configuration:

<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com *.mydomain.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} (.*)\.mydomain\.com [NC]
    RewriteRule (.*) http://mylocalserverdns.mydomain.com:8081/%1$1 [P]
</VirtualHost>

This makes request like http://subdomain1.mydomain.com/script?a=b to be transparently forwarded on server side to http://mylocalserverdns.mydomain.com:8081/subdomain1/script?a=b, so I can do whatever I want from there.

On my local server, I did the same thing to distribute my subdomains handler. I have, for instance two Java server applications that runs on ports 8088 and 8089 locally. All I had to do was another proxy forward, now internally

Local Server configuration:

<VirtualHost *:8081>
    ServerName mylocalserverdns.mydomain.com

    ProxyPass /app1 http://127.0.0.1:8088
    ProxyPassReverse /app1 http://127.0.0.1:8088
    ProxyPassReverse /app1 http://mylocalserverdns.mydomain.com:8088/app1

    ProxyPass /app2 http://127.0.0.1:8089
    ProxyPassReverse /app2 http://127.0.0.1:8089
    ProxyPassReverse /app2 http://mylocalserverdns.mydomain.com:8089/app2
</VirtualHost>

Hope this is worth if someone else is looking for the same alternative.

浪菊怪哟 2024-07-14 19:59:52

我认为大多数 DynamicDNS 服务都允许端口转发。

I think most DynamicDNS services allow port-forwarding.

尹雨沫 2024-07-14 19:59:52

询问您的 ISP 这是为什么,如果没有得到答案,请再次更换 ISP。

Ask your ISP why this is, and if you don't get an answer, switch ISPs again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文