다른 포트로 아파치 리디렉션
나는 한동안 이것으로 어려움을 겪었고 분명히 뭔가 잘못하고 있습니다.
같은 컴퓨터에 아파치 서버와 JBoss 서버가 있습니다. mydomain.com의 트래픽을 JBoss localhost : 8080 / example로 리디렉션하고 싶습니다. DNS는 현재 mydomain.com에 설정되어 있으며 브라우저에 입력하면 포트 80으로 바로 이동합니다.
제 질문은 특정 도메인 이름이 아파치에 올 때 (이 경우 "mydomain.com") 다른 포트로 리디렉션하는 방법입니다.
<VirtualHost ip.addr.is.here>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.com
ProxyPass http://mydomain.com http://localhost:8080/example
ProxyPassReverse http://mydomain.com http://localhost:8080/example
</VirtualHost>
제안 된 업데이트 -여전히 포트 8080으로 전달되지 않음
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.com
ServerAlias www.mydomain.com
ProxyPass http://mydomain.com http://localhost:8080/example
ProxyPassReverse http://mydomain.com http://localhost:8080/example
</VirtualHost>
http://example.com
ProxyPass 및 ProxyPassReverse에서 도메인 을 제외 하고로 남겨 두어야합니다 /
. 또한 경로를 리디렉션 할 위치 /
의 끝에 두어야합니다 example/
. 또한 http://example.com
vs. 와 관련하여 문제가 발생 http://www.example.com
했습니다. ServerName www.example.com 및 ServerAlias example.com을 만들 때까지 www 만 작동했습니다. 다음과 같이 가십시오.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias example.com
ProxyPass / http://localhost:8080/example/
ProxyPassReverse / http://localhost:8080/example/
</VirtualHost>
변경 한 후 필요한 모듈을 추가하고 아파치를 다시 시작하십시오.
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
다음 코드 로이 문제를 해결했습니다.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName myhost.com
ServerAlias ww.myhost.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
나는 또한 사용했다 :
a2enmod proxy_http
루트 도메인에서 Jenkins에 액세스 할 수 있도록이 작업을 정확히 수행하고 싶었습니다.
이것이 작동하도록 기본 사이트를 비활성화해야한다는 것을 알았습니다. 여기 내가 한 일이 있습니다.
$ sudo vi /etc/apache2/sites-available/jenkins
그리고 이것을 파일에 삽입하십시오 :
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.com
ServerAlias mydomain
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
다음으로 적절한 사이트를 활성화 / 비활성화해야합니다.
$ sudo a2ensite jenkins
$ sudo a2dissite default
$ sudo service apache2 reload
그것이 누군가를 돕기를 바랍니다.
Found this out by trial and error. If your configuration specifies a ServerName, then your VirtualHost directive will need to do the same. In the following example, awesome.example.com and amazing.example.com would both be forwarded to some local service running on port 4567.
ServerName example.com:80
<VirtualHost example.com:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName awesome.example.com
ServerAlias amazing.example.com
ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/
</VirtualHost>
I know this doesn't exactly answer the question, but I'm putting it here because this is the top search result for Apache port forwarding. So I figure it'll help somebody someday.
You have to make sure that the proxy is enabled on the server. You can do so by using the following commands:
a2enmod proxy
a2enmod proxy_http
service apache2 restart
This might be an old question, but here's what I did:
In a .conf file loaded by apache:
<VirtualHost *:80>
ServerName something.com
ProxyPass / http://localhost:8080/
</VirtualHost>
Explanation: Listen on all requests to the local machine's port 80. If I requested "http://something.com/somethingorother
", forward that request to "http://localhost:8080/somethingorother
". This should work for an external visitor because, according to the docs, it maps the remote request to the local server's space.
I'm running Apache 2.4.6-2ubuntu2.2, so I'm not sure how the "-2ubuntu2.2" affects the wider applicability of this answer.
After you make these changes, add the needed modules and restart apache
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
If you don't have to use a proxy to JBoss and mydomain.com:8080 can be "exposed" to the world, then I would do this.
<VirtualHost *:80>
ServerName mydomain.com
Redirect 301 / http://mydomain.com:8080/
</VirtualHost>
Just use a Reverse Proxy in your apache configuration (directly):
ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar
Look here for apache documentation of how to use the mod
Apache supports name based and IP based virtual hosts. It looks like you are using both, which is probably not what you need.
I think you're actually trying to set up name-based virtual hosting, and for that you don't need to specify the IP address.
Try < VirtualHost *:80> to bind to all IP addresses, unless you really want ip based virtual hosting. This may be the case if the server has several IP addresses, and you want to serve different sites on different addresses. The most common setup is (I would guess) name based virtual hosts.
You need 2 things:
- Add a
ServerAlias www.mydomain.com
to your config - change your proxypass to
ProxyPassMatch ^(.*)$ http://localhost:8080/example$1
, to possibly keep mod_dir and trailing slashes from interferring.
All are excellent insights to accessing ports via domain names on virtual servers. Do not forget, however, to enable virtual servers; this may be commented out:
NameVirtualHost *:80
<Directory "/home/dawba/www/">
allow from all
</Directory>
We run WSGI with an Apache server at the domain sxxxx.com and a golang server running on port 6800. Some firewalls seem to block domain names with ports. This was our solution:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName wsgi.sxxxx.com
DocumentRoot "/home/dxxxx/www"
<Directory "/home/dxxx/www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /py/ "/home/dxxxx/www/py/"
WSGIScriptAlias /wsgiprog /home/dxxxx/www/wsgiprog/Form/Start.wsgi
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName sxxxx.com
ServerAlias www.sxxxx.com
ProxyPass / http://localhost:6800/
ProxyPassReverse / http://localhost:6800/
</VirtualHost>
My apache listens to 2 different ports,
Listen 8080
Listen 80
I use the 80 when i want a transparent URL and do not put the port after the URL useful for google services that wont allow local url?
But i use the 8080 for internal developing where i use the port as a reference for a "dev environment"
This is working in ISPConfig too. In website list get inside a domain, click to Options tab, add these lines: ;
ProxyPass / http://localhost:8181/
ProxyPassReverse / http://localhost:8181/
Then go to website and wolaa :) This is working HTTPS protocol too.
참고URL : https://stackoverflow.com/questions/8541182/apache-redirect-to-another-port
'programing tip' 카테고리의 다른 글
c # /. net에서 예외를 문서화하는 방법 (0) | 2020.06.24 |
---|---|
여기서 XPath contains ()를 사용하는 방법은 무엇입니까? (0) | 2020.06.24 |
bash 스크립트에서 다른 명령으로 매개 변수를 어떻게 전달합니까? (0) | 2020.06.24 |
스칼라에서 ==와 .equals의 차이점은 무엇입니까? (0) | 2020.06.24 |
Sublime Text 2 편집기에 플러그인을 설치하는 방법은 무엇입니까? (0) | 2020.06.24 |