def _create_payments_route(): """ Add route to payments server. """ os.makedirs(Two1Composer.SITES_AVAILABLE_PATH, exist_ok=True) try: # write nginx route for payments server with open(os.path.join(Two1Composer.SITES_AVAILABLE_PATH, "payments"), 'w') as f: f.write("location /payment {\n" " proxy_pass http://payments:" + str(5000) + ";\n" " proxy_set_header Host $host;\n" " proxy_set_header X-Real-IP $remote_addr;\n" " proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n" "}\n") except Exception: raise exceptions.Two1ComposerRouteException()
def _create_service_route(service): """ Create route for container service. """ os.makedirs(Two1Composer.SITES_AVAILABLE_PATH, exist_ok=True) try: with open(os.path.join(Two1Composer.SITES_AVAILABLE_PATH, service), 'w') as f: f.write("location /" + service + " {\n" " rewrite ^/" + service + "(.*) /$1 break;\n" " proxy_pass http://" + service + ":" + str(5000) + ";\n" " proxy_set_header Host $host;\n" " proxy_set_header X-Real-IP $remote_addr;\n" " proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n" "}\n") except Exception: raise exceptions.Two1ComposerRouteException()