Allow Access to .well-known Folder For Let’s Encrypt/Certbot When Site Is Protected By HTTP Authentication

If you’re running Apache web server and you have your site protected with HTTP authentication but still want to allow Let’s Encrypt/Certbot to be able to issue a certificate you will have to allow access to the .well-known folder on your site. Otherwise they may give you an error and fail to issue you a certificate.

You can allow access to individual folders within that site by creating a .htaccess file in the folder (in this case within the .well-known folder) with the following contents:

This will allow anyone to access that folder thus allowing Let’s Encrypt/Certbot to verify your domain and issue you a certificate.

Install new ARK server on Ubuntu 16.04

First provision your server at your desired web host. I recommend using an 8GB Linode VPS. I could not get the server to start on a 4GB but maybe some day they will optimize it enough for that if you aren’t planning to have a lot of players. Linode is great because they have more RAM than some other hosts for the same price and it runs ARK great!

For the OS choice I prefer using Ubuntu 16.04 and this is what I’ll be using in this guide. We will also use the excellent ARK Server Tools. You don’t have download it yet, that part comes later.

Once you have your server running you can login to your shiney new SSH console. I’m logging in directly as root but if you are using another user you probably already know what you’re doing maybe you’re using a different host so just make sure to add sudo in front of all your commands until you switch to the steam user later on.

You might notice if you’ve already tried to update Ubuntu that it gets stuck at “Connecting to security.ubuntu.com” so before we update let’s fix that. Edit the file at /etc/gai.conf with your favourite editor. I use vi so type:

Find this line:

Remove the # at the start by using the arrow keys to go down and press Delete to uncomment the line and save the file with :wq Enter

Now you can update properly!

If it prompts anything about grub config just hit enter to keep the current grub config.

Now install the necessary packages (Note: If using sudo be sure to put it in front of apt-get as well):

Now let’s setup the firewall. If you have a static IP and want to allow only your IP to access your RCON and SSH you can run these:

Otherwise you can run these:

Now open some more ports:

And finally enable the firewall:

Now we are going to increase some limits on the file system and whatnot. Run these commands:

Now it’s time to reboot the server:

Once it comes back up and you’re logged back into your SSH console it’s time to install steam:

Now switch to the steam user:

As the steam user type these commands to install SteamCMD:

Now install the ARK server:

Edit config files in /etc/arkmanager/ or create /home/steam/.arkmanager.cfg
More info about the config files.

Upload any backups to /home/steam/ARK/ShooterGame/Saved/SavedArks. If you do this as root make sure you change the ownership on the files after:

Optionally install any mods you want to use:

And finally, start the server:

After a minute or two the server should be up and running and ready to play on. If not then you may have configured something wrong.

Website downloads instead of displaying

Recently I noticed a few sites had a page download instead of displaying when they were working perfectly fine before. I’m not 100% sure why but in my case the fix was to go into Virtualmin and toggle the PHP Version to some other version and back to my current one. I don’t know exactly what it changed, maybe it refreshed some config files somewhere. But it works and I wanted to make a note of it here in case it happens again.

Bash Script for Installing / Updating Java JDK RPM

Here’s a BASH script I wrote which downloads and installs the Java JDK RPM. Tested on CentOS 6.x. If you are looking to install on Ubuntu (or Mint) go here.

It also downloads the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files which are required for some applications.

You must replace the version variables in order to download the latest version. Here are the instructions for finding these.

  1. To find them go here and under the Java category go to Java SE.
  2. Click the big Java Download near the top.
  3. Click Accept License Agreement to view the links for the downloads.
  4. Find the Linux x64 if you are on a 64 bit OS or Linux i586 if you are on 32 bit. If you don’t know then you’re probably on 64 bit.
  5. Right click on the link in the right side column and go to Copy Link Location or Copy link address, etc.
  6. Now you can use this link you’ve copied to find the version numbers required. At the moment CURRENT and MINOR are not specified anywhere in the URL. Here is an image illustrating the MAJOR, REV and BUILD variables which you can update. In the future I am planning to write some regex to parse these out but haven’t yet.java
  7. Save the script below into a javainstall.sh file and make the file executable:
  8. Run the script to install / update java:

 

Notes:

  • Requires wget to be installed.
  • Requires unzip (for JCE) to be installed.
  • Does not update the JAVA_HOME or PATH environment variables. You can set them to /usr/java/latest which symlinks to the proper Java version.

Please report any issues.

Rdio Replacement

My wife and I freaked out a little bit when we heard Rdio is going away. Now we have to find an Rdio replacement! Since we live in Canada we can’t get Pandora yet so we can’t even hope to find in Pandora what we found in Rdio. Music is very important in our lives so it’s a pretty big deal when our favourite music streaming service goes out of business. We have Spotify since it came with my phone plan but it just doesn’t cut it for us, it doesn’t provide the same music discovery experience we loved on Rdio and the Roku app for Spotify really sucks!

After searching for a couple days we came up with some solutions for a replacement to Rdio which I will describe in some detail in this post in case anyone wants to try them out.
Continue reading “Rdio Replacement”

How to grep a $_REQUEST, $_GET or $_POST variable in all files recursively

Have you ever wanted to do a grep search on all files for a variable such as $_REQUEST, $_GET or $_POST but couldn’t figure it out? I have tried to do this a few times but end up just giving up because I don’t usually figure it out. This time I wanted to jot down my solution and figured I may as well put it here so everyone can see it. Skip to the end to see the right command to use.

Basically I wanted to recursively search through all files in the current folder including all sub-folders. In this case I was looking for $_REQUEST[‘ID’] in some PHP scripts. However when I tried to do a regular old grep -r on it…

… well obviously we can’t have the extra single quote around the ID part. So I tried escaping them:

Unfortunately that also doesn’t produce anything (ctrl+c out of that > prompt). OK, so there is a special way to escape single quotes on a shell. You have to break out of the single quote and then escape it. Let’s try that:

Well, that didn’t work. Now we have blankness again.

So I tried:

And it tells me grep: Invalid regular expression

Ok, so it must be using the [ as a regular expression. Alright well then let’s escape that too and see if we get our list of files yet.

Jackpot! That gives me a list of files, and the line of code with $_REQUEST[‘ID’] highlighted and that’s exactly what I am after. Note that there are no double quotes, they are all single quotes.

Redirect Apache ServerAlias to ServerName

I had a website that was moved to a new domain name but I wanted to make all the old URLs redirect to the new domain.

However, redirecting using a typical .htaccess redirect as shown below wouldn’t work because it was new using the old domain as a ServerAlias to the new domain/ServerName.

 

I found part of the solution to this here. I added in detection of HTTPS. Now whenever anyone accesses the site from a domain which isn’t example.com it will redirect to example.com including all the old URLs. I placed this in the Apache config file in the VirtualHost section for the domain rather than the .htaccess file. Replace example.com with the new domain/ServerName.

Recursively find and replace php.ini date.timezone

I recently had to update PHP on a server and the php.ini settings but then the date.timezone wasn’t set in a bunch of servers. So I decided just to search and replace them instead of doing them all individually.

Note the extra \ between America/Toronto which comes from the List of Supported Timezones.

Building mod_webpresence for ejabberd on CentOS

I keep forgetting how to setup the mod_webpresence for ejabberd whenever I happen to reinstall everything so I am typing it out here for future reference and maybe it’ll even be useful for others. The instructions aren’t 100% clear for me on the ejabberd-contrib github page since I have always had issues figuring it out. Hopefully these instructions will save some time in the future.

First I have to remove the existing erlang-kernel and all it’s packages and update to a new version of Erlang. I actually don’t know if this is necessary anymore but I update Erlang to the latest version since it was necessary in the past in order to properly be able to build the module.

Then I download latest Erlang package and install it instead. They have a bunch of operating systems including Ubuntu, CentOS, Fedora, Debian, Mac OS X and Windows.

From the ejabberd-contrib repository I upload to my ejabberd/lib folder the ejabberd-dev module and the mod_webpresence module. You can do this numerous ways. I simply download or clone the git repository and upload or move those module’s folders to the ejabberd/lib folder.

Then I go into the mod_webpresence folder, make the build.sh executable and run it.

The output shouldn’t have any errors or unfortunately something else is wrong. It should create a beam file in the ebin folder and say something like: Recompile: src/mod_webpresence

Next I copy the ejabberd/lib/mod_webpresence/ebin/mod_webpresence.beam file to ejabberd/lib/ejabberd-14.07/ebin/mod_webpresence.beam

Edit the ejabberd/conf/ejabberd.yml file and add the parts to the appropriate sections as shown below.

This part goes under the port: 5280 listen section or whatever port you are running the ejabberd_http module on that you want to serve the mod_webpresence from.

For example mine looks like this:

And this part goes down where all the other modules are defined. Make sure you update the /PATH/TO/ejabberd

Restart ejabberd and that should hopefully work out. If the ejabberd server doesn’t start then you probably should check the logs and see if you can see what’s wrong. If something is wrong then that really sucks! Especially if you don’t know much about Erlang. You will probably have to do some digging and try to figure it out.

If the server started fine and there are no errors in the logs then now you have to use a jabber client (I used Miranda NG) and login as the user you want to see the presence of. Access the Service Discovery under your jabber connection Services and Register with the webpresence service.

Once you do that it should send you a message telling you some examples and so forth like this:

If all is well then you should now be able to find or write your own app to detect and display your online presence. I ended up using the xml URL like this: jabber.example.com:5280/presence/jid/username/jabber.example.com/xml

Servers, Code, Websites, the Whole Internet

So many websites out there. They number in the billions. So many people trying to make their mark in the world wide web. Why start another website? Well I’m hoping to write about things I find useful, especially if I might want to reference it in the future, and especially if I’ve already had to go searching more than once for the information. If I just put it on this site then I won’t have to go searching all the time. Hopefully other people will also find this information useful.

Lately I’ve been doing a lot of coding, and a lot of gaming. Some day I’d like to code a game. But for now I’ll just stick to playing games and coding other things. The closest thing to coding a game I’ve done probably would be plugins for Minecraft. I’ve programmed several Minecraft/Bukkit plugins in the past but due to Minecraft being bought by Microsoft and all the turmoil surrounding all that I’m going to have to wait awhile to update those. I used to run a small Minecraft server which had a really nice little community but now I just have a small, whitelisted vanilla server running. But that isn’t really coding a game exactly, merely plugins for a game.

Although another thing I did when I first started programming many years ago when I was playing around in QuickBASIC was making somewhat of a clone of a game we had as kids called Alien Invaders Plus which I code named Happy Al. I don’t know what ever happened to that but it was a pretty good learning experience at the time. I kind of wish I still had it.

That was how we were taught back then, starting with Watcom BASIC and then eventually QBasic and then to Visual BASIC. After that I found QuickBASIC and played around with it for awhile. Even tried some C at one point and probably some others. I had even successfully dabbled in machine code with WinDasm32 at one point. Then I kind of moved into the field of web development which I’m now self-employed in (though I kind of suck at making graphics). I’ve been starting to work on some Android apps now as well. The new Android 5.0 Lollipop is coming out tomorrow so that is something to look at.

Maybe if things go well I can make some Android apps or maybe even some Android games. But I have a feeling that will be a ways off yet.