nginx – 404 on refresh

When you have configured a vhost for your site it might happen that when you access your application using your host name for eg http://<host-name>/ it all works good. Also you would be able to browse through links with in your app. The problem comes when you are in a path  for eg http://<host-name>/some/path and you hit refresh you get a 404 error page. After a lot of digging finally found this on github issues. This extra line in the vhost could save your day.

location /{
                try_files $uri $uri/ /index.html?/$request_uri;

After adding do a nginx service restart and everything works great !

intellij lombok

When you are using lombok plugin in your application everything works fine when running through a build/dependency management tool like gradle or maven. But running through intellij gives you errors like “cannot find symbol …”. You might have to enable the annotation processor at 2 places.

1.) Intellij Idea -> Preferences -> Compiler -> Annotation Processors

2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors


Nginx 403 forbidden

Though you have set all permissions right for files and folders which nginx needs to access you might face with the strange 403 error. That would be probably because of the SELinux. You would probably need to set enforce level to permissive. Run this command :

# setenforce Permissive

This will set the particular enforce level till reboot. Or else you can choose to change the SELinux context for your directory alone using this :

# chcon -Rt httpd_sys_content_t /path/to/www

Remember to change back the enforce level after using above command. This is the original stackoverflow post.

ansible unarchive – file not found

This strange thing happened where I tried this :

- name: Extract archive
  unarchive: src=src/dir/file.ext dest=dest/dir

It started complaining that “input file not found at src/dir/file.ext”. After trying out a lot of options like checking file path, checking permissions, I finally found from this stackoverflow post that “copy=no” would do the magic. So basically it was searching in the host machine, rather than the remote. Hence this worked

unarchive: src=src/dir/file.ext dest=dest/dir copy=no

Simple !