Implement HTTPS for Invoice Ninja Hosted via Softaculous

Hi,

I’m wanting implement SSL encryption for my domain. I’ve got invoice ninja on a sub-domain like invoice.mydomain.com and have enabled Let’s Encrypt via A2 Hosting’s cPanel. Unfortunately, it seems like no matter what Invoice Ninja always redirects to an insecure, HTTP address. Is there some code somewhere forcing this? Something I can change to make this work?

I did try cloning my installation via Softaculous and selected to clone to an HTTPS address; however, when I do that I just get an “oops something went wrong” when I try to visit the URL. It appears that it is still attempting to redirect to a non-HTTPS domain.

Here’s the error I’m getting:


[2018-01-30 00:25:49] production.ERROR: ***Symfony\Component\Debug\Exception\FatalErrorException*** [64] : /home/doublear/dev.doublearrowtech.com/bootstrap/cache/compiled.php [Line 17950] => App\Providers\RouteServiceProvider::App\Providers\{closure}(): Failed opening required '/home/doublear/dev.doublearrowtech.com/routes/api.php' (include_path='.:/opt/alt/php70/usr/share/pear')  {"context":"PHP","user_id":0,"account_id":0,"user_name":"","method":"GET","url":"http://dev.doublearrowtech.com/public/login","previous":"http://dev.doublearrowtech.com/public","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36","ip":"192.170.134.132","count":1,"is_console":"no","is_api":"no","db_server":"mysql"} []

Another question. In the .htaccess found in the public directory, it has this bit of code:


 # In case of running InvoiceNinja in a Subdomain like invoiceninja.example.com,
    # you have to enable the following line:
    # RewriteBase /

I enabled it, but then I got an error that says something about too many redirects. I disabled it and everything works fine. My instance of InvoiceNinja is on a sub-domain. What gives haha?

One thing to check is that APP_URL in the .env file starts with HTTPS.

Ok. I changed the APP_URL to HTTPS, but it’s still redirecting. I found this bit of code in the .htaccess


<IfModule mod_alias.c>
RedirectMatch 301 ^/$ http://invoice.doublearrowtech.com/public
</IfModule>

Would it possibly be the culprit? I’m not a backend person by any means, so sorry for all the questions!

Note: HTTPS for my domain and blog sub-domain is working just fine. Just can’t seem to get it working with my InvoiceNinja sub-domain.

Sorry, I’m not a backend person either…

I don’t recognize the code, I assume you added it?

I think it was added when I created a redirect in cPanel. I just installed a new instance of InvoiceNinja on a temporary sub-domain and that code isn’t there. HTTPS works fine on the new, temporary instance. When installing with a Softaculous, there’s an option to choose whether or not you are installing on HTTP or HTTPS. Originally, I didn’t have HTTPS enabled for my site, so I just installed InvoiceNinja on HTTP. I’m wanting to change that now, but it appears that there are quite a few things I have to tweak to get it to work.

I think I’ll just export the settings from my former InvoiceNinja installation into my temporary install, verify that all settings and configs are the same, and then delete the instance of InvoiceNinja that I have been using and clone the temporary install onto that my invoice.mydomain.com sub-domain. The only I am concerned about it porting over my white label license. I don’t want to lose that. Any ideas? Do I just copy the license code over from somewhere? I probably have the email when I purchased it somewhere in my archives :slight_smile:

If you use mysqldump to transfer the data your license will be included, otherwise you can reapply it manually.

I notice that exporting via JSON only grabs clients, products, invoice, quotes, and payments. Is there no way in InvoiceNinja to grab the rest of the data easily? (vendors, contacts, expenses, etc)

You’d need to use mysqldump

Ok. I just found an A2 tutorial on using it, so I’ll see how badly I can mess this up :slight_smile:

I got this done relatively easily. Thanks for all the help. Quick question: Is there a way to remove the /public from the URL? I see in one of the .htaccess it says I can “enable this line” to prevent the /public from showing. However, it doesn’t seem to work for me. I also see in the docs that it says I should be able to map the webroot to the /public directory. I don’t really know what that means or how to best accomplish that. Any pointers would be much appreciated. Thanks!

Maybe this will help:

https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-ubuntu-16-04