{"action":"closed","number":85,"pull_request":{"url":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/85","id":27898515,"html_url":"https://github.com/Dan-in-CA/OSPi/pull/85","diff_url":"https://github.com/Dan-in-CA/OSPi/pull/85.diff","patch_url":"https://github.com/Dan-in-CA/OSPi/pull/85.patch","issue_url":"https://api.github.com/repos/Dan-in-CA/OSPi/issues/85","number":85,"state":"closed","locked":false,"title":"Provide a way to allow reverse proxies & https","user":{"login":"mikedevita","id":2991640,"avatar_url":"https://avatars.githubusercontent.com/u/2991640?v=3","gravatar_id":"","url":"https://api.github.com/users/mikedevita","html_url":"https://github.com/mikedevita","followers_url":"https://api.github.com/users/mikedevita/followers","following_url":"https://api.github.com/users/mikedevita/following{/other_user}","gists_url":"https://api.github.com/users/mikedevita/gists{/gist_id}","starred_url":"https://api.github.com/users/mikedevita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikedevita/subscriptions","organizations_url":"https://api.github.com/users/mikedevita/orgs","repos_url":"https://api.github.com/users/mikedevita/repos","events_url":"https://api.github.com/users/mikedevita/events{/privacy}","received_events_url":"https://api.github.com/users/mikedevita/received_events","type":"User","site_admin":false},"body":"## explanation\r\nI run nginx at home to proxy all of my web traffic, and drop an ssl in front of everything. \r\n\r\nif you drop an SSL nginx reverse proxy infront of OSPi two defects occur.\r\n\r\n1. you are redirected to the `http://<hostname>/login` instead of `https://<hostname>/login`\r\n2. some/most of the static assets are loaded via `http://`, when really they should be loaded with `//`, this will allow them to be loaded for both https and http.\r\n\r\n\r\n## Steps to reproduce\r\n1. put an ssl nginx reverse proxy in front of the OSPi interface.\r\n2. visit the proxied url (in my case https://sprinkler.domain.com), it will redirect to `http://<hostname>/login`\r\n3. force that URL to be `https://<hostname>/login` and none of the static assets will load.\r\n\r\nI would be happy to fork, and attempt to fix these two things and issue a PR.\r\n\r\n## potential root cause\r\nAfter digging a bit I think this block is whats causing the issues, `wsgi.url_scheme` is always `http` because it doesn't know how to interpret the `X-Forwarded-Proto` header. \r\n\r\n```python\r\n        if env.get('wsgi.url_scheme') in ['http', 'https']:\r\n            ctx.protocol = env['wsgi.url_scheme']\r\n        elif env.get('HTTPS', '').lower() in ['on', 'true', '1']:\r\n            ctx.protocol = 'https'\r\n        else:\r\n            ctx.protocol = 'http'\r\n```\r\n\r\n## potential fix\r\n1. for the redirect issue, adding a conditional statement to check for the `X-Forwarded-Proto` header should work sufficiently. \r\n2. For the static assets, i'd think moving them to absolute paths instead of `http://....` would work fine as well.\r\n3. for google fonts in the base.css, just moving that to use `https` by default should work fine\r\n\r\n**web/application.py**\r\n```python\r\n        if env.get('HTTP_X_FORWARDED_PROTO') in ['http', 'https']:\r\n            ctx.protocol = env.get('HTTP_X_FORWARDED_PROTO')\r\n        elif env.get('wsgi.url_scheme') in ['http', 'https']:\r\n            ctx.protocol = env['wsgi.url_scheme']\r\n        elif env.get('HTTPS', '').lower() in ['on', 'true', '1']:\r\n            ctx.protocol = 'https'\r\n        else:\r\n            ctx.protocol = 'http'\r\n```\r\n\r\n**templates/base.html**\r\n```\r\n    <link href=\"/static/them......\r\n```","created_at":"2015-01-23T03:17:24Z","updated_at":"2015-02-01T19:58:39Z","closed_at":"2015-02-01T19:58:39Z","merged_at":"2015-02-01T19:58:39Z","merge_commit_sha":"de10f9043118cae95efc3777727244a99921ddd0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/85/commits","review_comments_url":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/85/comments","review_comment_url":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Dan-in-CA/OSPi/issues/85/comments","statuses_url":"https://api.github.com/repos/Dan-in-CA/OSPi/statuses/a59eccd4bf7ceddd359a4b18281d2167edf702d2","head":{"label":"mikedevita:master","ref":"master","sha":"a59eccd4bf7ceddd359a4b18281d2167edf702d2","user":{"login":"mikedevita","id":2991640,"avatar_url":"https://avatars.githubusercontent.com/u/2991640?v=3","gravatar_id":"","url":"https://api.github.com/users/mikedevita","html_url":"https://github.com/mikedevita","followers_url":"https://api.github.com/users/mikedevita/followers","following_url":"https://api.github.com/users/mikedevita/following{/other_user}","gists_url":"https://api.github.com/users/mikedevita/gists{/gist_id}","starred_url":"https://api.github.com/users/mikedevita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikedevita/subscriptions","organizations_url":"https://api.github.com/users/mikedevita/orgs","repos_url":"https://api.github.com/users/mikedevita/repos","events_url":"https://api.github.com/users/mikedevita/events{/privacy}","received_events_url":"https://api.github.com/users/mikedevita/received_events","type":"User","site_admin":false},"repo":{"id":29714126,"name":"OSPi","full_name":"mikedevita/OSPi","owner":{"login":"mikedevita","id":2991640,"avatar_url":"https://avatars.githubusercontent.com/u/2991640?v=3","gravatar_id":"","url":"https://api.github.com/users/mikedevita","html_url":"https://github.com/mikedevita","followers_url":"https://api.github.com/users/mikedevita/followers","following_url":"https://api.github.com/users/mikedevita/following{/other_user}","gists_url":"https://api.github.com/users/mikedevita/gists{/gist_id}","starred_url":"https://api.github.com/users/mikedevita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikedevita/subscriptions","organizations_url":"https://api.github.com/users/mikedevita/orgs","repos_url":"https://api.github.com/users/mikedevita/repos","events_url":"https://api.github.com/users/mikedevita/events{/privacy}","received_events_url":"https://api.github.com/users/mikedevita/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mikedevita/OSPi","description":"A highly cusomizable DIY irrigation/sprinkler controller based on Raspberry Pi","fork":true,"url":"https://api.github.com/repos/mikedevita/OSPi","forks_url":"https://api.github.com/repos/mikedevita/OSPi/forks","keys_url":"https://api.github.com/repos/mikedevita/OSPi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mikedevita/OSPi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mikedevita/OSPi/teams","hooks_url":"https://api.github.com/repos/mikedevita/OSPi/hooks","issue_events_url":"https://api.github.com/repos/mikedevita/OSPi/issues/events{/number}","events_url":"https://api.github.com/repos/mikedevita/OSPi/events","assignees_url":"https://api.github.com/repos/mikedevita/OSPi/assignees{/user}","branches_url":"https://api.github.com/repos/mikedevita/OSPi/branches{/branch}","tags_url":"https://api.github.com/repos/mikedevita/OSPi/tags","blobs_url":"https://api.github.com/repos/mikedevita/OSPi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mikedevita/OSPi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mikedevita/OSPi/git/refs{/sha}","trees_url":"https://api.github.com/repos/mikedevita/OSPi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mikedevita/OSPi/statuses/{sha}","languages_url":"https://api.github.com/repos/mikedevita/OSPi/languages","stargazers_url":"https://api.github.com/repos/mikedevita/OSPi/stargazers","contributors_url":"https://api.github.com/repos/mikedevita/OSPi/contributors","subscribers_url":"https://api.github.com/repos/mikedevita/OSPi/subscribers","subscription_url":"https://api.github.com/repos/mikedevita/OSPi/subscription","commits_url":"https://api.github.com/repos/mikedevita/OSPi/commits{/sha}","git_commits_url":"https://api.github.com/repos/mikedevita/OSPi/git/commits{/sha}","comments_url":"https://api.github.com/repos/mikedevita/OSPi/comments{/number}","issue_comment_url":"https://api.github.com/repos/mikedevita/OSPi/issues/comments/{number}","contents_url":"https://api.github.com/repos/mikedevita/OSPi/contents/{+path}","compare_url":"https://api.github.com/repos/mikedevita/OSPi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mikedevita/OSPi/merges","archive_url":"https://api.github.com/repos/mikedevita/OSPi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mikedevita/OSPi/downloads","issues_url":"https://api.github.com/repos/mikedevita/OSPi/issues{/number}","pulls_url":"https://api.github.com/repos/mikedevita/OSPi/pulls{/number}","milestones_url":"https://api.github.com/repos/mikedevita/OSPi/milestones{/number}","notifications_url":"https://api.github.com/repos/mikedevita/OSPi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mikedevita/OSPi/labels{/name}","releases_url":"https://api.github.com/repos/mikedevita/OSPi/releases{/id}","created_at":"2015-01-23T03:11:26Z","updated_at":"2015-01-23T04:24:49Z","pushed_at":"2015-01-23T04:24:47Z","git_url":"git://github.com/mikedevita/OSPi.git","ssh_url":"git@github.com:mikedevita/OSPi.git","clone_url":"https://github.com/mikedevita/OSPi.git","svn_url":"https://github.com/mikedevita/OSPi","homepage":"","size":2406,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Dan-in-CA:master","ref":"master","sha":"aedec4a192a56caa8fc5c83200d5c4a8d81bd9f1","user":{"login":"Dan-in-CA","id":4706639,"avatar_url":"https://avatars.githubusercontent.com/u/4706639?v=3","gravatar_id":"","url":"https://api.github.com/users/Dan-in-CA","html_url":"https://github.com/Dan-in-CA","followers_url":"https://api.github.com/users/Dan-in-CA/followers","following_url":"https://api.github.com/users/Dan-in-CA/following{/other_user}","gists_url":"https://api.github.com/users/Dan-in-CA/gists{/gist_id}","starred_url":"https://api.github.com/users/Dan-in-CA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dan-in-CA/subscriptions","organizations_url":"https://api.github.com/users/Dan-in-CA/orgs","repos_url":"https://api.github.com/users/Dan-in-CA/repos","events_url":"https://api.github.com/users/Dan-in-CA/events{/privacy}","received_events_url":"https://api.github.com/users/Dan-in-CA/received_events","type":"User","site_admin":false},"repo":{"id":12367093,"name":"OSPi","full_name":"Dan-in-CA/OSPi","owner":{"login":"Dan-in-CA","id":4706639,"avatar_url":"https://avatars.githubusercontent.com/u/4706639?v=3","gravatar_id":"","url":"https://api.github.com/users/Dan-in-CA","html_url":"https://github.com/Dan-in-CA","followers_url":"https://api.github.com/users/Dan-in-CA/followers","following_url":"https://api.github.com/users/Dan-in-CA/following{/other_user}","gists_url":"https://api.github.com/users/Dan-in-CA/gists{/gist_id}","starred_url":"https://api.github.com/users/Dan-in-CA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dan-in-CA/subscriptions","organizations_url":"https://api.github.com/users/Dan-in-CA/orgs","repos_url":"https://api.github.com/users/Dan-in-CA/repos","events_url":"https://api.github.com/users/Dan-in-CA/events{/privacy}","received_events_url":"https://api.github.com/users/Dan-in-CA/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Dan-in-CA/OSPi","description":"A highly cusomizable DIY irrigation/sprinkler controller based on Raspberry Pi","fork":false,"url":"https://api.github.com/repos/Dan-in-CA/OSPi","forks_url":"https://api.github.com/repos/Dan-in-CA/OSPi/forks","keys_url":"https://api.github.com/repos/Dan-in-CA/OSPi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dan-in-CA/OSPi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dan-in-CA/OSPi/teams","hooks_url":"https://api.github.com/repos/Dan-in-CA/OSPi/hooks","issue_events_url":"https://api.github.com/repos/Dan-in-CA/OSPi/issues/events{/number}","events_url":"https://api.github.com/repos/Dan-in-CA/OSPi/events","assignees_url":"https://api.github.com/repos/Dan-in-CA/OSPi/assignees{/user}","branches_url":"https://api.github.com/repos/Dan-in-CA/OSPi/branches{/branch}","tags_url":"https://api.github.com/repos/Dan-in-CA/OSPi/tags","blobs_url":"https://api.github.com/repos/Dan-in-CA/OSPi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dan-in-CA/OSPi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dan-in-CA/OSPi/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dan-in-CA/OSPi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dan-in-CA/OSPi/statuses/{sha}","languages_url":"https://api.github.com/repos/Dan-in-CA/OSPi/languages","stargazers_url":"https://api.github.com/repos/Dan-in-CA/OSPi/stargazers","contributors_url":"https://api.github.com/repos/Dan-in-CA/OSPi/contributors","subscribers_url":"https://api.github.com/repos/Dan-in-CA/OSPi/subscribers","subscription_url":"https://api.github.com/repos/Dan-in-CA/OSPi/subscription","commits_url":"https://api.github.com/repos/Dan-in-CA/OSPi/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dan-in-CA/OSPi/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dan-in-CA/OSPi/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dan-in-CA/OSPi/issues/comments/{number}","contents_url":"https://api.github.com/repos/Dan-in-CA/OSPi/contents/{+path}","compare_url":"https://api.github.com/repos/Dan-in-CA/OSPi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dan-in-CA/OSPi/merges","archive_url":"https://api.github.com/repos/Dan-in-CA/OSPi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dan-in-CA/OSPi/downloads","issues_url":"https://api.github.com/repos/Dan-in-CA/OSPi/issues{/number}","pulls_url":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls{/number}","milestones_url":"https://api.github.com/repos/Dan-in-CA/OSPi/milestones{/number}","notifications_url":"https://api.github.com/repos/Dan-in-CA/OSPi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dan-in-CA/OSPi/labels{/name}","releases_url":"https://api.github.com/repos/Dan-in-CA/OSPi/releases{/id}","created_at":"2013-08-25T22:59:53Z","updated_at":"2015-02-01T19:58:40Z","pushed_at":"2015-02-01T19:58:39Z","git_url":"git://github.com/Dan-in-CA/OSPi.git","ssh_url":"git@github.com:Dan-in-CA/OSPi.git","clone_url":"https://github.com/Dan-in-CA/OSPi.git","svn_url":"https://github.com/Dan-in-CA/OSPi","homepage":"","size":3673,"stargazers_count":38,"watchers_count":38,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":5,"forks":37,"open_issues":5,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/85"},"html":{"href":"https://github.com/Dan-in-CA/OSPi/pull/85"},"issue":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/issues/85"},"comments":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/Dan-in-CA/OSPi/statuses/a59eccd4bf7ceddd359a4b18281d2167edf702d2"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"Dan-in-CA","id":4706639,"avatar_url":"https://avatars.githubusercontent.com/u/4706639?v=3","gravatar_id":"","url":"https://api.github.com/users/Dan-in-CA","html_url":"https://github.com/Dan-in-CA","followers_url":"https://api.github.com/users/Dan-in-CA/followers","following_url":"https://api.github.com/users/Dan-in-CA/following{/other_user}","gists_url":"https://api.github.com/users/Dan-in-CA/gists{/gist_id}","starred_url":"https://api.github.com/users/Dan-in-CA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dan-in-CA/subscriptions","organizations_url":"https://api.github.com/users/Dan-in-CA/orgs","repos_url":"https://api.github.com/users/Dan-in-CA/repos","events_url":"https://api.github.com/users/Dan-in-CA/events{/privacy}","received_events_url":"https://api.github.com/users/Dan-in-CA/received_events","type":"User","site_admin":false},"comments":7,"review_comments":0,"commits":4,"additions":13,"deletions":10,"changed_files":3}}