diff --git a/roles/api/defaults/main.yml b/roles/api/defaults/main.yml index e0f2ee9..9e26b3a 100644 --- a/roles/api/defaults/main.yml +++ b/roles/api/defaults/main.yml @@ -1,4 +1,5 @@ almanach_port: 8000 +almanach_listen_ip: 0.0.0.0 almanach_user: almanach almanach_group: almanach almanach_service_name: almanach-api @@ -6,8 +7,3 @@ almanach_service_name: almanach-api almanach_nginx_hostname: default almanach_nginx_port: 80 almanach_nginx_log_file: /var/log/nginx/default_access.log - -use_nginx: True - -use_netfilter: False -netfilter_iface: eth0 diff --git a/roles/api/tasks/main.yml b/roles/api/tasks/main.yml index 3f74ea8..0827990 100644 --- a/roles/api/tasks/main.yml +++ b/roles/api/tasks/main.yml @@ -13,10 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: nginx.yml - when: use_nginx == True - -- include: netfilter.yml - when: use_netfilter == True - - include: init_upstart.yml diff --git a/roles/api/tasks/netfilter.yml b/roles/api/tasks/netfilter.yml deleted file mode 100644 index 26c9b5a..0000000 --- a/roles/api/tasks/netfilter.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -# Copyright 2016, Internap Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Forward port 80 to Almanach port - iptables: table=nat chain=PREROUTING in_interface={{ netfilter_iface }} protocol=tcp match=tcp destination_port=80 jump=REDIRECT to_ports={{ almanach_port }} diff --git a/roles/api/tasks/nginx.yml b/roles/api/tasks/nginx.yml deleted file mode 100644 index 76568b1..0000000 --- a/roles/api/tasks/nginx.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -# Copyright 2016, Internap Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Install nginx - apt: name=nginx state=present - -- name: Remove default nginx config - file: name=/etc/nginx/sites-enabled/default state=absent - -- name: Configure nginx - template: - src: "nginx.vhost.conf.j2" - dest: /etc/nginx/sites-enabled/00-almanach-api - mode: "0644" - owner: "root" - group: "root" - register: nginx_config - notify: - - Restart nginx diff --git a/roles/api/templates/almanach-api-upstart.init.j2 b/roles/api/templates/almanach-api-upstart.init.j2 index b49f9af..9fd2e15 100644 --- a/roles/api/templates/almanach-api-upstart.init.j2 +++ b/roles/api/templates/almanach-api-upstart.init.j2 @@ -10,5 +10,5 @@ setuid {{ almanach_user }} setgid {{ almanach_group }} script - exec {{ almanach_app_dir }}/bin/almanach api {{ almanach_config_file }} --port {{ almanach_port }} --logging {{ almanach_logging_config_file }} + exec {{ almanach_app_dir }}/bin/almanach api {{ almanach_config_file }} --host {{ almanach_listen_ip }} --port {{ almanach_port }} --logging {{ almanach_logging_config_file }} end script diff --git a/roles/api/templates/nginx.vhost.conf.j2 b/roles/api/templates/nginx.vhost.conf.j2 deleted file mode 100644 index 77c6099..0000000 --- a/roles/api/templates/nginx.vhost.conf.j2 +++ /dev/null @@ -1,13 +0,0 @@ -server { - listen {{ almanach_nginx_port }}; - server_name {{ almanach_nginx_hostname }}; - - access_log {{ almanach_nginx_log_file }}; - - location / { - proxy_pass http://127.0.0.1:{{ almanach_port }}; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -}