Try   HackMD

multiples webs - apache server

Vas a fer canvis a una màquina virtual. Si ja la tens importada, i has fet una snapshot (punt de recuperació) passa directament al pas 5)

  1. descàrrega, importa la vm i engega-la

ubuntu_server_ova

  1. accedim a la vm a través d'una connexió ssh gràcies al port forwarding

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
!!! a la màquina física

ssh -p 40022 alumne01@127.0.0.1
  1. comprova que te connectivitat
ping -c 3 8.8.8.8
ping -c 3 google.com
  1. atura la vm i crea una snapshot per poder tornar al punt de partida
  2. instal·la apache i unzip (doncs el necessitarem més tard)
sudo apt update
sudo apt install apache2 unzip
  1. descarrega la web d'exemple
wget -O /tmp/example-site.zip https://s3.eu-west-2.amazonaws.com/tiiny.host/example-site.zip
  1. consulta quines webs estan disponibles
a2query -s
  1. deshabilita la web per defecte
sudo a2dissite 000-default.conf
  1. prepara el fitxer de configuració de la nova web
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/001-primeraweb.edu.conf
  1. modifica el contingut del nou fitxer, indicant (i descomentant) el ServerName (què posarem al navegador per accedir a la web) i el DomumentRoot (el lloc/directori/carpeta on copiaràs el contingut de la web: index.html & friends)
sudo vi /etc/apache2/sites-available/001-primeraweb.edu.conf
  1. crea la nova carpeta a /var/www
sudo mkdir /var/www/primeraweb.edu
  1. habilita la nova web
sudo a2ensite 001-primeraweb.edu.conf
  1. comprova que estigui habilitada
a2query -s
  1. descomprimeix el contingut de la web al nou directori
sudo unzip -d /var/www/primeraweb.edu /tmp/example-site.zip
  1. per a la resolució de noms ens caldrà al menys fer-ho de manera estàtica (sic)
grep primeraweb /etc/hosts || (echo "127.0.0.1 www.primeraweb.edu" | sudo tee -a /etc/hosts) 
  1. reinicia l'apache
sudo systemctl reload apache2.service
  1. comprova que funciona a la vm
curl 127.0.0.1
curl www.primeraweb.edu

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
accés des de la teva màquina física a través del port forwarding de virtualbox

  1. per accedir per nom des d'un navegador ens caldrà muntar un proxy

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
a la màquina física

ssh -N -f -D 39999 -p 40022 alumne01@127.0.0.1
  1. accés amb diferents navegadors (prova amb chrome millor)
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
    a windows has de posar la "ruta" completa a l'executable.

a) Brave (realitza la resolució en el proxy)

brave-browser --proxy-server="socks5://127.0.0.1:39999" 

b) Chromium també

chromium-browser --proxy-server="socks5://127.0.0.1:39999"

c) i Chrome, quan no està gestionat (managed) també

google-chrome --user-data-dir=/tmp --proxy-server="socks5://127.0.0.1:39999"

c.win) chrome a windows

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
tanca qualsevol altra finestra de chrome
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
verifica que la "ruta" c:\ és la correcta: si cal comprova-ho a les propietats de la icona de chrome.

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --proxy-server="socks5://127.0.0.1:39999"

d) firefox (gràficament)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

configurar un proxy socks5 amb ip 127.0.0.1 i port 39999 i que faci resolució de noms al proxy (casella de selecció #2 del final del diàleg del proxy)
  1. ara ja pots posar al navegador
http://www.primeraweb.edu

Alternativa gràfica
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

després de completar el pas 17

  1. instal·la un entorn GUI a la VM i el firefox
sudo apt install gnome-session gnome-terminal firefox
  1. reinicia la màquina virtual i des del firefox accedeix a
http://www.primeraweb.edu

referències

Tot l'article està bé però te porte directe al reenviament dinàmic