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.

  • Hi  

    Are you can try with proxy server ? Like nginx.

    Y share with you my config.

    nginx/nginx.conf

    http {
        ...
        include /etc/nginx/conf.d/*.conf;
    }

    ./nginx/conf.d/<name_your_local_instance>.conf

    server {
                    listen   80;
                    server_name sugarent1100ex.loc;
                    location / {
                            proxy_pass http://localhost:8080/sugar/sugarent1100ex.loc/;
                            include /etc/nginx/proxy_params;
                    }
            }
    

    ./nginx/proxy_params

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    
    client_max_body_size 100M;
    client_body_buffer_size 1m;
    proxy_intercept_errors on;
    proxy_buffering on;
    proxy_buffer_size 128k;
    proxy_buffers 256 16k;
    proxy_busy_buffers_size 256k;
    proxy_temp_file_write_size 256k;
    proxy_max_temp_file_size 0;
    proxy_read_timeout 1200s;
    proxy_connect_timeout 1200s;
    
    
    #client_body_buffer_size 16k;
    #client_header_buffer_size 1k;
    #client_max_body_size 25m;
    #large_client_header_buffers 4 8k;
    

    The .htaccess looks like this

    # BEGIN SUGARCRM RESTRICTIONS
    # Fix mimetype for logo.svg (SP-1395)
    AddType     image/svg+xml     .svg
    AddType     application/json  .json
    AddType     application/javascript  .js
    
    <IfModule mod_rewrite.c>
        Options +FollowSymLinks
        RewriteEngine On
        RewriteBase /sugar/sugarent1000ex.loc/
        RewriteRule (?i)\.git - [F]
        RewriteRule (?i)\.log$ - [F]
        RewriteRule (?i)^bin/ - [F]
        RewriteRule (?i)^cache/diagnostic/ - [F]
        RewriteRule (?i)^composer\.(json|lock)$ - [F]
    ...

    You can add the name instance into hosts file.

    Into windows you can follow the tutorial here

    I hope to be helpful

    Take care.

  • 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