snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

SSL not redirecting for CSS & JS after install

Open brownac25 opened this issue 9 years ago • 18 comments

Expected Behavior (or desired behavior if a feature request)

Site to be completely loaded over SSL

Actual Behavior

After installing, when I go to the pre-flight setup all of the CSS, and JS files are loading over http instead of https. I have set the APP_URL in the .env file and uncommented the two lines for SSL in the .htaccess file inside the public directory.


Please confirm you have done the following before posting your bug report:


Please provide answers to these questions before posting your bug report:

Ran the install through the git clone method (v 3.6.6) and am running on centos 7 with apache. None of the CSS and JS loads over https in the pre-flight setup, so I have not completed the pre-flight install. I do not receive any error messages from debug mode or in the storage/logs folder.

brownac25 avatar Jun 17 '17 17:06 brownac25

Is the APP_URL an https address? Alsok, are you running behind any kind of proxy or anything? Have you tried clearing the config cache?

snipe avatar Jun 19 '17 21:06 snipe

Hi,

Yes, I do have the APP_URL in the .env file set as an https address and it is not being run behind a proxy or anything. I believe I have tried clearing the cache config already, but would be glad to attempt again if you can send me the command.

brownac25 avatar Jun 19 '17 21:06 brownac25

I ran the following commands, if this is what you are referring to about clearing the config cache: php composer.phar install --no-dev --prefer-source php artisan config:clear php composer.phar dump-autoload php artisan migrate php artisan view:clear

brownac25 avatar Jun 19 '17 21:06 brownac25

php artisan config:clear https://snipe-it.readme.io/docs/clearing-the-config-cache

snipe avatar Jun 19 '17 21:06 snipe

When you view the HTML source on the page, do the JS and CSS files point to http:// or https://?

snipe avatar Jun 19 '17 21:06 snipe

When I viewed it, the JS and CSS files pointed to http://

I was able to get past the install by using URL::forceSchema('https'); in app/http/route.php; However, I am now experiencing an issue with the forms to add models, companies, ect. All the forms are showing an http:// for the action attributes instead of https://, so I am unable to submit forms to insert data.

brownac25 avatar Jun 19 '17 22:06 brownac25

Please answer my previous question.

You should not have to make any source code changes to get this to work as expected.

snipe avatar Jun 20 '17 01:06 snipe

That was only to verify if the CSS and JS was preventing completion of pre-flight. I have since changed it back and All CSS and JS is loading over http instead of https.

I'm not sure which question you are referring to? The last question I saw was if the JS and CSS files point to http:// or https:// which they do when viewing the HTML Source (show http:// that is).

brownac25 avatar Jun 20 '17 01:06 brownac25

If you change the APP_URL in your env to something weird, clear your config cache, and reload, does the URL reflect those changes?

snipe avatar Jun 20 '17 22:06 snipe

(The URL in the HTML source, I mean)

snipe avatar Jun 20 '17 22:06 snipe

I changed the APP_URL in env to gibberish (sdfsdfsd) and cleared the config and view cache. The URL in HTML source code does not reflect any changes.

it still shows the original address with http://

brownac25 avatar Jun 20 '17 22:06 brownac25

If you change anything else in the config (mysql DB password, for example), clear config cache and reload, does it break? (Also try restarting the web server.)

snipe avatar Jun 21 '17 03:06 snipe

Hi,

I changed the DB host to completely blank and I get an "Whoops, it looks like something went wrong" page and I get a PDO exception in the storage/logs file. It works like normal when I change it back. I also tried completely removing the password and it gives another PDO exeption. I did clear config, cache, and restart the apache web service for each change.

For some reason though, changing the APP_URL doesn't seem to affect anything though...

brownac25 avatar Jun 21 '17 23:06 brownac25

I think it may have to do with the host header. I just changed the servername in the apache host header and it seems to have changed the links on the HTML source pages.

brownac25 avatar Jun 22 '17 00:06 brownac25

Below is what I have for the host header:

<VirtualHost *:80>
    ServerName inventory2.site.com
    DocumentRoot /var/www/html/snipeit/public
    Redirect permanent "/" "https://inventory2.site.com/"

	<Directory /var/www/html/snipeit/public>
		Allow From All
		AllowOverride All
		Options +Indexes
	</Directory>

</VirtualHost>

<VirtualHost *:443>
    	ServerName inventory2.site.com
	DocumentRoot /var/www/html/snipeit/public

	<Directory /var/www/html/snipeit/public>
		Allow From All
		AllowOverride All
		Options +Indexes
	</Directory>
</VirtualHost>

brownac25 avatar Jun 22 '17 00:06 brownac25

Finally solved it.

It was a case of an previous .conf file and needing the SSLCertificateFile, SSL CertificateKey, etc inside the host header as well.

CLOSING!!

Thank you for all of your assistance!

brownac25 avatar Jun 22 '17 04:06 brownac25

@brownac25 Hey Dude! I have now the same problem, could you maybe help me out with that?

Sylencer91 avatar Oct 08 '20 07:10 Sylencer91

So I had a similar issue since I was a bit of a noob at configuring Virtual Hosts. What @brownac25 said is correct, if you copying the SSLCertificateFile , SSLCertificateKeyFile and SSLCertificateChainFile directives into your snipeit apache site.conf it fixes the issue (I have multiple sites setup). With multiple sites and the default site enabled make sure to put a ServerName directive for your default site.

Working conf

<VirtualHost *:80>
    ServerName snipeit.example.com
    DocumentRoot /var/www/snipeit/public
    Redirect permanent / https://snipeit.example.com/

    ErrorLog ${APACHE_LOG_DIR}/ssl_error_snipeit.log
    CustomLog ${APACHE_LOG_DIR}/ssl_access_snipeit.log combined

    <Directory /var/www/snipeit/public>
        Allow From All
        AllowOverride All
        Options +Indexes
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerName snipeit.example.com
    DocumentRoot /var/www/snipeit/public

    ErrorLog ${APACHE_LOG_DIR}/ssl_error_snipeit.log
    CustomLog ${APACHE_LOG_DIR}/ssl_access_snipeit.log combined

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/yourcertname.crt
    SSLCertificateKeyFile /etc/ssl/private/yourcertprivate.key
    SSLCertificateChainFile /etc/ssl/certs/yourintermediatecerts.crt

    <Directory /var/www/snipeit/public>
        Allow From All
        AllowOverride All
        Options +Indexes
    </Directory>
</VirtualHost>

sjwestern avatar Mar 24 '21 23:03 sjwestern