{"action":"created","comment":{"url":"https://api.github.com/repos/roots/trellis/pulls/comments/52704730","id":52704730,"diff_hunk":"@@ -0,0 +1,20 @@\n+# Make coding more python3-ish\n+from __future__ import (absolute_import, division, print_function)\n+__metaclass__ = type\n+\n+import re\n+\n+def reverse_www(host=None):\n+    ''' Add or remove the www subdomain '''\n+    match = re.match(r'www\\.(.+)', host)\n+    if match:\n+        return match.group(1)\n+    return 'www.' + host","path":"filter_plugins/trellis_filters.py","position":12,"original_position":12,"commit_id":"c3a2e4e36c2f721014530a82a624439d39fabaa6","original_commit_id":"c3a2e4e36c2f721014530a82a624439d39fabaa6","user":{"login":"swalkinshaw","id":295605,"avatar_url":"https://avatars.githubusercontent.com/u/295605?v=3","gravatar_id":"","url":"https://api.github.com/users/swalkinshaw","html_url":"https://github.com/swalkinshaw","followers_url":"https://api.github.com/users/swalkinshaw/followers","following_url":"https://api.github.com/users/swalkinshaw/following{/other_user}","gists_url":"https://api.github.com/users/swalkinshaw/gists{/gist_id}","starred_url":"https://api.github.com/users/swalkinshaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swalkinshaw/subscriptions","organizations_url":"https://api.github.com/users/swalkinshaw/orgs","repos_url":"https://api.github.com/users/swalkinshaw/repos","events_url":"https://api.github.com/users/swalkinshaw/events{/privacy}","received_events_url":"https://api.github.com/users/swalkinshaw/received_events","type":"User","site_admin":false},"body":"Not sure what idiomatic Python is but seems like this should be under the `else` condition.","created_at":"2016-02-12T04:34:38Z","updated_at":"2016-02-12T04:34:38Z","html_url":"https://github.com/roots/trellis/pull/486#discussion_r52704730","pull_request_url":"https://api.github.com/repos/roots/trellis/pulls/486","_links":{"self":{"href":"https://api.github.com/repos/roots/trellis/pulls/comments/52704730"},"html":{"href":"https://github.com/roots/trellis/pull/486#discussion_r52704730"},"pull_request":{"href":"https://api.github.com/repos/roots/trellis/pulls/486"}}},"pull_request":{"url":"https://api.github.com/repos/roots/trellis/pulls/486","id":59125463,"html_url":"https://github.com/roots/trellis/pull/486","diff_url":"https://github.com/roots/trellis/pull/486.diff","patch_url":"https://github.com/roots/trellis/pull/486.patch","issue_url":"https://api.github.com/repos/roots/trellis/issues/486","number":486,"state":"open","locked":false,"title":"Add reverse_www filter to fix www_redirect","user":{"login":"fullyint","id":7338513,"avatar_url":"https://avatars.githubusercontent.com/u/7338513?v=3","gravatar_id":"","url":"https://api.github.com/users/fullyint","html_url":"https://github.com/fullyint","followers_url":"https://api.github.com/users/fullyint/followers","following_url":"https://api.github.com/users/fullyint/following{/other_user}","gists_url":"https://api.github.com/users/fullyint/gists{/gist_id}","starred_url":"https://api.github.com/users/fullyint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullyint/subscriptions","organizations_url":"https://api.github.com/users/fullyint/orgs","repos_url":"https://api.github.com/users/fullyint/repos","events_url":"https://api.github.com/users/fullyint/events{/privacy}","received_events_url":"https://api.github.com/users/fullyint/received_events","type":"User","site_admin":false},"body":"@QWp6t pointed out that **when SSL is enabled**, `wordpress-site.conf.j2` will fail to forward http://www.example.com => https://example.com. The current template produces the conf below. \r\n\r\n```\r\nserver {\r\n  listen 80;\r\n  server_name example.com;\r\n  return 301 https://$host$request_uri;\r\n}\r\n\r\nserver {\r\n  listen 443 ssl http2;\r\n  server_name www.example.com;\r\n  return 301 $scheme://example.com$request_uri;\r\n}\r\n```\r\n- The first server block doesn't match http://www.example.com because it doesn't include a match for www. \r\n- The second server block doesn't match http://www.example.com because it listens only on 443.\r\n\r\nThis PR enables the first server block to also match www, taking the first step of forwarding http://www.example.com => https://www.example.com. Then the second server block will pick it up and strip the www.\r\n\r\nI created and implemented a custom `reverse_www` filter to make the templating simpler.","created_at":"2016-02-12T02:19:42Z","updated_at":"2016-02-12T04:34:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e6ed1680719152b93ffb4c4575d06fed181f5ca8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/roots/trellis/pulls/486/commits","review_comments_url":"https://api.github.com/repos/roots/trellis/pulls/486/comments","review_comment_url":"https://api.github.com/repos/roots/trellis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/roots/trellis/issues/486/comments","statuses_url":"https://api.github.com/repos/roots/trellis/statuses/c3a2e4e36c2f721014530a82a624439d39fabaa6","head":{"label":"fullyint:www-filter","ref":"www-filter","sha":"c3a2e4e36c2f721014530a82a624439d39fabaa6","user":{"login":"fullyint","id":7338513,"avatar_url":"https://avatars.githubusercontent.com/u/7338513?v=3","gravatar_id":"","url":"https://api.github.com/users/fullyint","html_url":"https://github.com/fullyint","followers_url":"https://api.github.com/users/fullyint/followers","following_url":"https://api.github.com/users/fullyint/following{/other_user}","gists_url":"https://api.github.com/users/fullyint/gists{/gist_id}","starred_url":"https://api.github.com/users/fullyint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullyint/subscriptions","organizations_url":"https://api.github.com/users/fullyint/orgs","repos_url":"https://api.github.com/users/fullyint/repos","events_url":"https://api.github.com/users/fullyint/events{/privacy}","received_events_url":"https://api.github.com/users/fullyint/received_events","type":"User","site_admin":false},"repo":{"id":20627252,"name":"trellis","full_name":"fullyint/trellis","owner":{"login":"fullyint","id":7338513,"avatar_url":"https://avatars.githubusercontent.com/u/7338513?v=3","gravatar_id":"","url":"https://api.github.com/users/fullyint","html_url":"https://github.com/fullyint","followers_url":"https://api.github.com/users/fullyint/followers","following_url":"https://api.github.com/users/fullyint/following{/other_user}","gists_url":"https://api.github.com/users/fullyint/gists{/gist_id}","starred_url":"https://api.github.com/users/fullyint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullyint/subscriptions","organizations_url":"https://api.github.com/users/fullyint/orgs","repos_url":"https://api.github.com/users/fullyint/repos","events_url":"https://api.github.com/users/fullyint/events{/privacy}","received_events_url":"https://api.github.com/users/fullyint/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fullyint/trellis","description":"Ansible playbooks for a Bedrock based WordPress LEMP app server","fork":true,"url":"https://api.github.com/repos/fullyint/trellis","forks_url":"https://api.github.com/repos/fullyint/trellis/forks","keys_url":"https://api.github.com/repos/fullyint/trellis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fullyint/trellis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fullyint/trellis/teams","hooks_url":"https://api.github.com/repos/fullyint/trellis/hooks","issue_events_url":"https://api.github.com/repos/fullyint/trellis/issues/events{/number}","events_url":"https://api.github.com/repos/fullyint/trellis/events","assignees_url":"https://api.github.com/repos/fullyint/trellis/assignees{/user}","branches_url":"https://api.github.com/repos/fullyint/trellis/branches{/branch}","tags_url":"https://api.github.com/repos/fullyint/trellis/tags","blobs_url":"https://api.github.com/repos/fullyint/trellis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fullyint/trellis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fullyint/trellis/git/refs{/sha}","trees_url":"https://api.github.com/repos/fullyint/trellis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fullyint/trellis/statuses/{sha}","languages_url":"https://api.github.com/repos/fullyint/trellis/languages","stargazers_url":"https://api.github.com/repos/fullyint/trellis/stargazers","contributors_url":"https://api.github.com/repos/fullyint/trellis/contributors","subscribers_url":"https://api.github.com/repos/fullyint/trellis/subscribers","subscription_url":"https://api.github.com/repos/fullyint/trellis/subscription","commits_url":"https://api.github.com/repos/fullyint/trellis/commits{/sha}","git_commits_url":"https://api.github.com/repos/fullyint/trellis/git/commits{/sha}","comments_url":"https://api.github.com/repos/fullyint/trellis/comments{/number}","issue_comment_url":"https://api.github.com/repos/fullyint/trellis/issues/comments{/number}","contents_url":"https://api.github.com/repos/fullyint/trellis/contents/{+path}","compare_url":"https://api.github.com/repos/fullyint/trellis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fullyint/trellis/merges","archive_url":"https://api.github.com/repos/fullyint/trellis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fullyint/trellis/downloads","issues_url":"https://api.github.com/repos/fullyint/trellis/issues{/number}","pulls_url":"https://api.github.com/repos/fullyint/trellis/pulls{/number}","milestones_url":"https://api.github.com/repos/fullyint/trellis/milestones{/number}","notifications_url":"https://api.github.com/repos/fullyint/trellis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fullyint/trellis/labels{/name}","releases_url":"https://api.github.com/repos/fullyint/trellis/releases{/id}","deployments_url":"https://api.github.com/repos/fullyint/trellis/deployments","created_at":"2014-06-08T21:46:39Z","updated_at":"2016-02-09T08:16:49Z","pushed_at":"2016-02-12T01:58:31Z","git_url":"git://github.com/fullyint/trellis.git","ssh_url":"git@github.com:fullyint/trellis.git","clone_url":"https://github.com/fullyint/trellis.git","svn_url":"https://github.com/fullyint/trellis","homepage":"http://roots.io/wordpress-stack/","size":525,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"roots:master","ref":"master","sha":"3354a00e3863561f1333e21134c493c14d98b095","user":{"login":"roots","id":4986074,"avatar_url":"https://avatars.githubusercontent.com/u/4986074?v=3","gravatar_id":"","url":"https://api.github.com/users/roots","html_url":"https://github.com/roots","followers_url":"https://api.github.com/users/roots/followers","following_url":"https://api.github.com/users/roots/following{/other_user}","gists_url":"https://api.github.com/users/roots/gists{/gist_id}","starred_url":"https://api.github.com/users/roots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roots/subscriptions","organizations_url":"https://api.github.com/users/roots/orgs","repos_url":"https://api.github.com/users/roots/repos","events_url":"https://api.github.com/users/roots/events{/privacy}","received_events_url":"https://api.github.com/users/roots/received_events","type":"Organization","site_admin":false},"repo":{"id":18852165,"name":"trellis","full_name":"roots/trellis","owner":{"login":"roots","id":4986074,"avatar_url":"https://avatars.githubusercontent.com/u/4986074?v=3","gravatar_id":"","url":"https://api.github.com/users/roots","html_url":"https://github.com/roots","followers_url":"https://api.github.com/users/roots/followers","following_url":"https://api.github.com/users/roots/following{/other_user}","gists_url":"https://api.github.com/users/roots/gists{/gist_id}","starred_url":"https://api.github.com/users/roots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roots/subscriptions","organizations_url":"https://api.github.com/users/roots/orgs","repos_url":"https://api.github.com/users/roots/repos","events_url":"https://api.github.com/users/roots/events{/privacy}","received_events_url":"https://api.github.com/users/roots/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/roots/trellis","description":"End-to-end automated WordPress environment management via Ansible.","fork":false,"url":"https://api.github.com/repos/roots/trellis","forks_url":"https://api.github.com/repos/roots/trellis/forks","keys_url":"https://api.github.com/repos/roots/trellis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/roots/trellis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/roots/trellis/teams","hooks_url":"https://api.github.com/repos/roots/trellis/hooks","issue_events_url":"https://api.github.com/repos/roots/trellis/issues/events{/number}","events_url":"https://api.github.com/repos/roots/trellis/events","assignees_url":"https://api.github.com/repos/roots/trellis/assignees{/user}","branches_url":"https://api.github.com/repos/roots/trellis/branches{/branch}","tags_url":"https://api.github.com/repos/roots/trellis/tags","blobs_url":"https://api.github.com/repos/roots/trellis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/roots/trellis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/roots/trellis/git/refs{/sha}","trees_url":"https://api.github.com/repos/roots/trellis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/roots/trellis/statuses/{sha}","languages_url":"https://api.github.com/repos/roots/trellis/languages","stargazers_url":"https://api.github.com/repos/roots/trellis/stargazers","contributors_url":"https://api.github.com/repos/roots/trellis/contributors","subscribers_url":"https://api.github.com/repos/roots/trellis/subscribers","subscription_url":"https://api.github.com/repos/roots/trellis/subscription","commits_url":"https://api.github.com/repos/roots/trellis/commits{/sha}","git_commits_url":"https://api.github.com/repos/roots/trellis/git/commits{/sha}","comments_url":"https://api.github.com/repos/roots/trellis/comments{/number}","issue_comment_url":"https://api.github.com/repos/roots/trellis/issues/comments{/number}","contents_url":"https://api.github.com/repos/roots/trellis/contents/{+path}","compare_url":"https://api.github.com/repos/roots/trellis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/roots/trellis/merges","archive_url":"https://api.github.com/repos/roots/trellis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/roots/trellis/downloads","issues_url":"https://api.github.com/repos/roots/trellis/issues{/number}","pulls_url":"https://api.github.com/repos/roots/trellis/pulls{/number}","milestones_url":"https://api.github.com/repos/roots/trellis/milestones{/number}","notifications_url":"https://api.github.com/repos/roots/trellis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/roots/trellis/labels{/name}","releases_url":"https://api.github.com/repos/roots/trellis/releases{/id}","deployments_url":"https://api.github.com/repos/roots/trellis/deployments","created_at":"2014-04-16T19:08:33Z","updated_at":"2016-02-11T09:40:16Z","pushed_at":"2016-02-12T02:19:42Z","git_url":"git://github.com/roots/trellis.git","ssh_url":"git@github.com:roots/trellis.git","clone_url":"https://github.com/roots/trellis.git","svn_url":"https://github.com/roots/trellis","homepage":"https://roots.io/trellis/","size":996,"stargazers_count":725,"watchers_count":725,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":250,"mirror_url":null,"open_issues_count":14,"forks":250,"open_issues":14,"watchers":725,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/roots/trellis/pulls/486"},"html":{"href":"https://github.com/roots/trellis/pull/486"},"issue":{"href":"https://api.github.com/repos/roots/trellis/issues/486"},"comments":{"href":"https://api.github.com/repos/roots/trellis/issues/486/comments"},"review_comments":{"href":"https://api.github.com/repos/roots/trellis/pulls/486/comments"},"review_comment":{"href":"https://api.github.com/repos/roots/trellis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/roots/trellis/pulls/486/commits"},"statuses":{"href":"https://api.github.com/repos/roots/trellis/statuses/c3a2e4e36c2f721014530a82a624439d39fabaa6"}}}}