Vagrant HTTP vs HTTPS

I am still trying to get vagrant working for my development team and I ran into another issue that seems like it should be a breeze to solve but after hours on google I still cant make it work

The only port opened up on Vagrant is 8080 meaning no SSL The problem is that while Sugar works fine on port 80 it requests all its fonts and graphics on HTTPS.


This is a normal Sugar Call, note it goes to HTTP as it should


While this is a font call attempting to be called on HTTPS

I cant find a reason why it would be on HTTPS, my config.php is fine.  Nothing in the .htaccess file would do it.

So I thought I would just enable SSL.  Pretty easy, done it a thousand times.   I create the certificate and create the virtual host and nothing.  Can not connect.  I have a feeling this is a vagrant thing but I cant find anything that matches.

Parents
  • OK, Here is what you do

    1. Get vagrant up and running and then ssh into it ('vagrant ssh')
    2. sudo mkdir /etc/apache2/ssl
    3. sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
      1. Answer all the questions as best you can
    4. sudo a2enmod ssl
    5. sudo nano /etc/apache2/sites-enabled/sugar.conf
      Listen 8080
      <VirtualHost *:8080>
              ServerName localhost
              DocumentRoot /var/www/html
              Redirect permanent / https://localhost:8443/sugar/
      </VirtualHost>
      <Directory "/var/www/html/sugar">
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
      </Directory>
      
      <VirtualHost *:443>
          ServerName        localhost
          DocumentRoot    /var/www/html
          DirectoryIndex    index.php index.html index.htm
      
          <Directory "/var/www/html/sugar">
              AllowOverride All
              Allow from All
          </Directory>
      
          SSLEngine on
          SSLCertificateFile    /etc/apache2/ssl/server.crt
          SSLCertificateKeyFile /etc/apache2/ssl/server.key
      </VirtualHost>

    Last you have to update your Vagrantfile, its in the root of your Sugar directory.  Look for a like like this one

    # config.vm.network "forwarded_port", guest: 80, host: 8080

    and add this under it

    config.vm.network "forwarded_port", guest: 443, host: 44

    Now restart your vagrant ('vagrant halt' and 'vagrant up') and you should now be able to use

    https://localhost/sugar

Reply
  • OK, Here is what you do

    1. Get vagrant up and running and then ssh into it ('vagrant ssh')
    2. sudo mkdir /etc/apache2/ssl
    3. sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
      1. Answer all the questions as best you can
    4. sudo a2enmod ssl
    5. sudo nano /etc/apache2/sites-enabled/sugar.conf
      Listen 8080
      <VirtualHost *:8080>
              ServerName localhost
              DocumentRoot /var/www/html
              Redirect permanent / https://localhost:8443/sugar/
      </VirtualHost>
      <Directory "/var/www/html/sugar">
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
      </Directory>
      
      <VirtualHost *:443>
          ServerName        localhost
          DocumentRoot    /var/www/html
          DirectoryIndex    index.php index.html index.htm
      
          <Directory "/var/www/html/sugar">
              AllowOverride All
              Allow from All
          </Directory>
      
          SSLEngine on
          SSLCertificateFile    /etc/apache2/ssl/server.crt
          SSLCertificateKeyFile /etc/apache2/ssl/server.key
      </VirtualHost>

    Last you have to update your Vagrantfile, its in the root of your Sugar directory.  Look for a like like this one

    # config.vm.network "forwarded_port", guest: 80, host: 8080

    and add this under it

    config.vm.network "forwarded_port", guest: 443, host: 44

    Now restart your vagrant ('vagrant halt' and 'vagrant up') and you should now be able to use

    https://localhost/sugar

Children
No Data