Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda