Skip to content
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

Nginx: add nginx to shell server #53

Merged
merged 4 commits into from
Sep 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ansible/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- misc
- ldap-nss
- security
- nginx

- name: Run Docker postinit task
include_tasks: tasks/docker/main.post.yml
Expand Down
37 changes: 37 additions & 0 deletions ansible/tasks/nginx/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- name: Install nginx
apt:
name={{ item }}
with_items:
- nginx

- name: Setup sites-enabled/hashbang-http
register: nginxconf
copy:
dest: /etc/nginx/sites-enabled/hashbang-http
content: |
# Hashbang server configuration
# ref: https://gist.github.com/RyanSquared/e59c7e274abef06e63b0e47e46997b00
#
server {
listen 80;
listen [::]:80;

server_name "~^(?<user>[a-zA-Z0-9]+)\.(?<server>\w{2}\d{1})\.hashbang\.sh$";

location / {
proxy_pass http://unix:/home/$user/.nginx.sock;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

- name: Remove default nginx site
file:
state: absent
path: /etc/nginx/sites-enabled/default
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also remove /etc/nginx/sites-available/default ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/nginx/sites-available/default is src of this symlink. there is no point to remove the original copy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed


- name: Restart nginx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to make this optional so that it doesn't fail if systemd isn't running (for instance, when setting up a build with Docker)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ought to be a handler, but that would depend on #68

when: nginxconf.changed
service: name=nginx state=restarted enabled=yes
ignore_errors: yes # ignore error when systemd isn't running