-
Notifications
You must be signed in to change notification settings - Fork 33
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
||
- name: Restart nginx | ||
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. 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) 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. done. 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 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 |
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.
Should we also remove /etc/nginx/sites-available/default ?
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.
/etc/nginx/sites-available/default is src of this symlink. there is no point to remove the original copy
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.
Agreed