Refactored Nginx and fixed restart. Simplified the code for debugging.