Redireccionamiento de Apache a otro puerto
He luchado con esto durante algún tiempo y definitivamente estoy haciendo algo mal.
Tengo un servidor apache y un servidor JBoss en la misma máquina. Me gustaría redirigir el tráfico para mydomain.com para JBoss localhost: 8080 / ejemplo. El DNS está configurado actualmente para mydomain.com y irá directamente al puerto 80 cuando se ingrese en el navegador.
Mi pregunta es cómo puedo redirigir a un puerto diferente cuando un cierto nombre de dominio llega a apache (en este caso, "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>
ACTUALIZADO con sugerencias - Todavía no se reenvía al puerto 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>
13 answers
Debe dejar fuera el dominio http://example.com
en ProxyPass y ProxyPassReverse y dejarlo como /
. Además, es necesario dejar el /
al final de example/
a donde se redirige. Además, tuve algunos problemas con http://example.com
vs. http://www.example.com
- solo el www funcionó hasta que hice el ServerName www.example.com, y las ServerAlias example.com.Dale una oportunidad a lo siguiente.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias example.com
ProxyPass / http://localhost:8080/example/
ProxyPassReverse / http://localhost:8080/example/
</VirtualHost>
Después de realizar estos cambios, agregue los módulos necesarios y reinicie apache
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-05 01:24:46
Resolví este problema con el siguiente código:
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>
También utilicé:
a2enmod proxy_http
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-11-06 01:50:38
Quería hacer exactamente esto para poder acceder a Jenkins desde el dominio raíz.
Descubrí que tenía que desactivar el sitio predeterminado para que esto funcionara. Esto es exactamente lo que hice.
$ sudo vi /etc/apache2/sites-available/jenkins
E inserte esto en el archivo:
<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>
A continuación, debe habilitar / deshabilitar los sitios apropiados:
$ sudo a2ensite jenkins
$ sudo a2dissite default
$ sudo service apache2 reload
Espero que ayude a alguien.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-07-29 05:45:27
Averiguó esto por ensayo y error. Si su configuración especifica un ServerName, entonces su directiva VirtualHost tendrá que hacer lo mismo. En el siguiente ejemplo, awesome.example.com y amazing.example.com ambos serían reenviados a algún servicio local que se ejecuta en el puerto 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>
Sé que esto no responde exactamente a la pregunta, pero lo estoy poniendo aquí porque este es el principal resultado de búsqueda para el reenvío de puertos Apache. Así que me imagino que ayudará a alguien algún día.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-24 20:05:55
Debe asegurarse de que el proxy esté habilitado en el servidor. Puede hacerlo utilizando los siguientes comandos:
a2enmod proxy
a2enmod proxy_http
service apache2 restart
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-11 02:32:36
Si no tienes que usar un proxy para JBoss y mydomain.com:8080 puede ser "expuesto" al mundo, entonces haría esto.
<VirtualHost *:80>
ServerName mydomain.com
Redirect 301 / http://mydomain.com:8080/
</VirtualHost>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-16 23:12:16
Esta podría ser una vieja pregunta, pero esto es lo que hice:
En a .archivo conf cargado por apache:
<VirtualHost *:80>
ServerName something.com
ProxyPass / http://localhost:8080/
</VirtualHost>
Explicación: Escucha todas las peticiones al puerto 80 de la máquina local. Si solicito " http://something.com/somethingorother
", remítalo a "http://localhost:8080/somethingorother
". Esto debería funcionar para un visitante externo porque, según los documentos, asigna la solicitud remota al espacio del servidor local.
Estoy ejecutando Apache 2.4.6-2ubuntu2.2, por lo que no estoy seguro de cómo el "-2ubuntu2. 2" afecta la aplicabilidad más amplia de esta respuesta.
Después de realizar estos cambios, agregue los módulos necesarios y reinicie apache
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-05 01:25:48
Simplemente use un Proxy inverso en su configuración de apache (directamente):
ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar
Busque aquí la documentación de apache sobre cómo usar el mod
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-06-13 10:44:38
Apache admite hosts virtuales basados en nombres y basados en IP. Parece que estás usando ambos, que probablemente no es lo que necesitas.
Creo que en realidad está tratando de configurar alojamiento virtual basado en nombres, y para eso no necesita especificar la dirección IP.
Intente para enlazar a todas las direcciones IP, a menos que realmente desee alojamiento virtual basado en ip. Este puede ser el caso si el servidor tiene varias direcciones IP, y desea servir diferentes sitios en diferentes direcciones. La configuración más común es (supongo) hosts virtuales basados en nombres.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-16 23:36:37
Necesitas 2 cosas:
- Añade un
ServerAlias www.mydomain.com
a tu configuración - cambie su proxypass a
ProxyPassMatch ^(.*)$ http://localhost:8080/example$1
, para posiblemente evitar que mod_dir y las barras finales interfieran.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-16 23:45:35
Todos son excelentes conocimientos para acceder a puertos a través de nombres de dominio en servidores virtuales. No olvide, sin embargo, habilitar servidores virtuales; esto puede ser comentado:
NameVirtualHost *:80
<Directory "/home/dawba/www/">
allow from all
</Directory>
Ejecutamos WSGI con un servidor Apache en el dominio sxxxx.com y un servidor golang corriendo en el puerto 6800. Algunos firewalls parecen bloquear nombres de dominio con puertos. Esta fue nuestra solución:
<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>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-13 21:46:25
Mi apache escucha 2 puertos diferentes,
Listen 8080
Listen 80
Utilizo el 80 cuando quiero una URL transparente y no pongo el puerto después de la URL útil para los servicios de Google que no permiten url local?
Pero uso el 8080 para el desarrollo interno donde uso el puerto como referencia para un "entorno dev"
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-22 13:24:26
Esto también funciona en ISPConfig. En la lista de sitios web, ingrese a un dominio, haga clic en la pestaña Opciones, agregue estas líneas:;
ProxyPass / http://localhost:8181/
ProxyPassReverse / http://localhost:8181/
Luego vaya a sitio web y wolaa :) Esto también funciona con el protocolo HTTPS.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-07 18:05:30