Straight to the point

Category: Uncategorized (Page 1 of 2)

Managing AWS SimpleAD from Linux

SimpleAD is a managed directory service that is powered by a Samba 4 Active Directory Compatible Server. User accounts can be created in SimpleAD to access AWS applications such as AWS Client VPN, Amazon WorkSpaces, Amazon WorkDocs, or Amazon WorkMail.

I have used this service for user authentication in Client VPN. One of the challenges that we faced is that the user management in SimpleAD was very biased to Windows OS and not linux. It was not a good idea to manage a Windows server just to manage users where as all the other applications are running in Linux. After some googling, I came to know about some tools which can be used to manage users in SimpleAD. But none of them are complete or easy to understand. This inspired me to write a post on the same.

Install the packages samba-common, adcli on the Linux OS by which you are trying to manage the AD.

Take note of the Directory domain name and the DNS servers from the AWS SimpleAD console UI. The below example assumes username is the user that we are administering, “password” is the password, is the directory domain and, as the DNS servers for the directory

Create User

Delete User

List users

More adcli commands can be found here

Simulate upstream proxy timeout using nodejs

This is something that I have came across while tuning an nginx server which has multiple tomcat instances as upstream. We were trying to adjust the read timeout of the upstream proxies. It is hard to simulate this by stopping the backend as it will throw a 503 bad gateway. So, for simulating this, we used a nodejs script.

Fix 404 error for permalinks while using SSL in wordpress

This was an issue I have faced while setting up this blog. I was getting 404 errors for all the post links in this blog when selecting the non default permalink structure with SSL. 

First thing I tried was to regenerate the .htaccess file. Removed the existing .htaccess file in the WordPress root folder. Regenerated the file by switching  the permalink again. That didnt worked for me. The fix was something with the web sever level. Finally, I found the fix. 

The directory tag is required in ssl virtual host config of apache same as of http port 80, to allow override redirect rules using .htaccess of wordpress.


Thanks to this digitalocean thread 

Monitor ECS agent uptime using crontab and SNS

The Amazon ECS container agent allows container instances to connect to your cluster. If this agent is down for some reason, deployments to the service won’t be reflected in the instance and can cause discrepancy.
Here is a one-liner to check if ECS agent container is running. If it is not running, we are making use of AWS SNS service to send a notification to a topic.
if [ -z $(docker ps -f “name=ecs-agent” -f “status=running” -q) ]; then /usr/bin/aws –region=us-east-1 sns publish –topic-arn “arn:aws:sns:us-east-1:123456789012:Topicname” –message “ECS Agent is not running in $HOSTNAME.”; fi
Make sure that the instance role has permissions to publish to the required topic and the topic is already configured.

Get any user’s public key from github

This is useful when you are giving SSH access to a server. Basically, we have to append the public key to ~/.ssh/authorized_keys.

Replace the with real github username.

Custom error code in nginx

In some cases, we might need to throw a custom/different error code for a specific issue. For example, we can throw a different error to the end user even if the backend node is down. We can do that in nginx as in the example below.
server {
    listen       8080;
    error_page   502 503 504 =204 /temperror;
    location /temperror {
      return 204;
Now the user will only see a 204 even if its 503 in real

Renaming git branch

1. Rename your local branch.
If you are on the branch you want to rename:
git branch -m new-name
2. Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
3. Reset the upstream branch for the new-name local branch. Switch to the branch and then:
git push origin -u new-name

Delete a git commit that is already pushed

git log
 to check the commit list.
For example, commit 7f6d03 was before the 2 wrongful commits and we want to restore to that commit .
Force push that commit as the new master:
git push origin +7f6d03:master
The + is interpreted as forced push.
Another way
You can also use git reset to undo things. Then force push.
git reset 7f6d03 –hard
git push origin -f
« Older posts

© 2020 Devopslife

Theme by Anders NorenUp ↑