Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
Create Virtual Hosts in Vagrant Server

I am running Apache server with vagrant and I want to access multiple websites from host machine. Current setup looks like this:

Vagrantfile:

Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/trusty64"
    config.ssh.forward_agent = true
    config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "127.0.0.1", id: 'apache_http'
    config.vm.network "forwarded_port", guest: 443, host: 443, host_ip: "127.0.0.1", id: 'apache_https'
    config.vm.network "forwarded_port", guest: 22, host: 22, host_ip: "127.0.0.1", id: 'ssh'
    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.synced_folder ".", "/var/www/"
end

/etc/hosts

127.0.0.1 localhost
192.168.33.10 website.com
192.168.33.10 a.website.com
192.168.33.10 b.website.com

/etc/apache2/sites-available/website.conf

<VirtualHost *:80>
    ServerAdmin example@gmail.com
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /var/www/website/public_html
    ErrorLog /var/www/website/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost _default_:443>
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /var/www/website/public_html
    ErrorLog /var/www/website/error.log
    SSLEngine on
    SSLCertificateKeyFile /etc/apache2/ssl/website.key
    SSLCertificateFile /etc/apache2/ssl/website.cert
</VirtualHost>

I can access the website from inside vagrant box by: curl https://website.com -k. How can I expose it to the host machine?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The steps are correct.

  1. In your Vagrantfile you dont need to add the forwarding port if you use a static IP as you'll access your VM/guest using the IP directly

  2. You need to update the hosts file from your host machine. On windows the file is located under C:\Windows\System32\drivers\etc

You can now access https://website.com directly from your host

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda