{"id":24199627,"url":"https://github.com/fivepoint-0/nginxlocationmanager","last_synced_at":"2025-07-06T04:37:07.053Z","repository":{"id":114760985,"uuid":"408855081","full_name":"fivepoint-0/NginxLocationManager","owner":"fivepoint-0","description":"this is a config manager for nginx locations","archived":false,"fork":false,"pushed_at":"2021-10-14T14:20:30.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T20:41:40.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivepoint-0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-21T14:34:31.000Z","updated_at":"2021-10-14T14:20:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e43deea-45d5-494a-8a53-491b23eda781","html_url":"https://github.com/fivepoint-0/NginxLocationManager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivepoint-0%2FNginxLocationManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivepoint-0%2FNginxLocationManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivepoint-0%2FNginxLocationManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivepoint-0%2FNginxLocationManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivepoint-0","download_url":"https://codeload.github.com/fivepoint-0/NginxLocationManager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241638479,"owners_count":19995209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-13T20:37:22.715Z","updated_at":"2025-03-03T09:24:14.242Z","avatar_url":"https://github.com/fivepoint-0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nginx Location Manager Utility\n\n## Purpose\n\nThis utility is meant to create easy (right now only) proxy locations in any Nginx config that has:\n\n1. One `server` that the config is managing locations for.\n2. The beginning of the locations config starts with a line that says: `##### START LOCATIONS CONFIG #####` and ends the locations config with `##### END LOCATIONS CONFIG #####`.\n\n## Import a configuration\n\nWe'll be using the default configuration file for Nginx. To instantiate the manager, do:\n\n```python\nfrom NginxLocationManager import NginxLocationManager\n\nmgr = NginxLocationManager()\nmgr.parse_locations()\n```\n\n## Creating a location\n```python\nmgr.create_location(\"/app-1.0.0/\")\n```\n\nEvery Location has four properties:\n1. `id` === Location ID in the config.\n2. `uri` === URI match for this location.\n3. `options` === Options for the Nginx location.\n4. `port` === Port used for proxy at this location.\n\n## Deleting a Location\n\nTo delete a location with a certain id, use this:\n```python\nmgr.delete_location(1)\n```\n\n## View internal config of manager\n\nTo see the Nginx config that would be generated when saving the configuration from the manager, you can use:\n```python\nmgr.get_internal_config_string()\n```\n\nIf you just want to see the locations part of the config, you can use:\n```python\nmgr.get_locations_config_string()\n```\n\n## Saving Config to Disk\n\nTo save the config the manager has internally to the config file specified when creating the manager, perform:\n```python\nmgr.save_locations()\n```\n\n## Example usage file\n\nHere is a file to start you off:\n```python\n#!/usr/bin/python3\n\nfrom NginxLocationManager import NginxLocationManager\nfrom NginxLocationManager.NginxLocationOption import ProxyPassOption, ProxyRedirectOption, SetHeaderOption\n\nmgr = NginxLocationManager()\nmgr.parse_locations()\n\nmgr.create_location(\"/app-v1.1.0/\", options=[\n    SetHeaderOption('X-Real-IP', '$remote_addr'), \n    SetHeaderOption('X-Forwarded-For', '$http_host'), \n    SetHeaderOption('Host', '$remote_addr'), \n    SetHeaderOption('X-NginX-Proxy', 'true'), \n    ProxyPassOption('http://127.0.0.1:4000/'), \n    ProxyRedirectOption('http://', 'https://')\n])\n\nmgr.create_location(\"/app-v1.2.0/\")\n\nprint(mgr.get_internal_config_string())\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivepoint-0%2Fnginxlocationmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivepoint-0%2Fnginxlocationmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivepoint-0%2Fnginxlocationmanager/lists"}