-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor Proxied Hosts #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| --- | ||
| # these are pretty hacky, but it should work | ||
| # Get port information from the hosted service | ||
| - name: get eru ports | ||
| when: name == "eru" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: true | ||
| shell: | | ||
| for c in $(docker ps | awk '/eru/{ print $1 }'); do | ||
| docker port $c 5501 | cut -d ':' -f 2 | ||
| docker port $c 5502 | cut -d ':' -f 2 | ||
| done | ||
| args: | ||
| executable: /bin/bash | ||
| register: eru_target_ports | ||
|
|
||
| - name: get socket server ports | ||
| when: name == "api-socket-server" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: true | ||
| shell: | | ||
| for c in $(docker ps | awk '/api-socket-server/{ print $1 }'); do | ||
| docker port $c 80 | cut -d ':' -f 2 | ||
| done | ||
| args: | ||
| executable: /bin/bash | ||
| register: socket_target_ports | ||
|
|
||
| # everything from this point on is deligated to the nginx host | ||
|
|
||
| - name: print target ports | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| debug: | ||
| msg: | | ||
| eru ports -- {{ eru_target_ports }} | ||
| socket ports -- {{ socket_target_ports }} | ||
|
|
||
| - name: print target IP address | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| debug: | ||
| msg: ip -- {{ target_ip_address }} | ||
|
|
||
| - name: assert nginx config directory | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: yes | ||
| file: | ||
| state: directory | ||
| dest: /etc/nginx | ||
|
|
||
| - name: assert nginx sites-available directory | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: yes | ||
| file: | ||
| state: directory | ||
| dest: /etc/nginx/sites-available | ||
|
|
||
| - name: assert nginx sites-enable directory | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: yes | ||
| file: | ||
| state: directory | ||
| dest: /etc/nginx/sites-enable | ||
|
|
||
| - name: put configuration in place | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: yes | ||
| template: | ||
| src: "{{ item }}" | ||
| dest: /etc/nginx/sites-available/{{ item }} | ||
| with_items: "{{ templates }}" | ||
|
|
||
| - name: link configuration to enable | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: yes | ||
| file: | ||
| state: link | ||
| dest: /etc/nginx/sites-enabled/{{ item }} | ||
| src: /etc/nginx/sites-available/{{ item }} | ||
| with_items: "{{ templates }}" | ||
|
|
||
| - name: reload nginx | ||
| delegate_to: "{{ nginx_host }}" | ||
| tags: [ configure_proxy, deploy ] | ||
| become: yes | ||
| shell: > | ||
| docker ps | | ||
| awk '/nginx/{ print $1 }' | | ||
| xargs -n 1 docker kill --signal SIGHUP | ||
| args: | ||
| executable: /bin/bash | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ server { | |
|
|
||
| location / { | ||
| expires 300; | ||
| proxy_pass http://{{ eru_server_hostname }}:{{ ports.stdout_lines[0] | trim }}; | ||
| proxy_pass http://{{ target_ip_address }}:{{ eru_target_ports.stdout_lines[0] | trim }}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename file to not have eru if this is generic?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file isn't generic. the templates live in the |
||
| proxy_set_header Host $host; | ||
| proxy_set_header x-real-ip $remote_addr; | ||
| proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; | ||
|
|
@@ -44,7 +44,7 @@ server { | |
| } | ||
|
|
||
| location /graphql { | ||
| proxy_pass http://{{ eru_server_hostname }}:{{ ports.stdout_lines[1] | trim }}; | ||
| proxy_pass http://{{ target_ip_address }}:{{ eru_target_ports.stdout_lines[1] | trim }}; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header x-real-ip $remote_addr; | ||
| proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename
eru?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, this and the next task, they both are the implementation of "how to get the ports for a service". I don't quite like how it's done, but I don't know that I can get around it. I'll see...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, this and the next task, they both are the implementation of "how to get the ports for a service". I don't quite like how it's done, but I don't know that I can get around it. I'll see...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right - basically I'd have to modify container start or kill/start to always get the ports the same way at the end, but then templates can use them differently. I'm up for more ideas, but I'm not sure what to do