Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #50 from mvdbeek/nginx-proxy-prefix
Browse files Browse the repository at this point in the history
Configurable nginx proxy prefix
  • Loading branch information
bgruening committed Feb 4, 2016
2 parents 1638e27 + 2d0969b commit 7730cdb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ nginx_conf_path: /etc/nginx/nginx.conf
nginx_conf_directory: /etc/nginx/conf.d
nginx_upload_store_path: "/tmp/nginx_upload_store"

# Use nginx_*_location variables to control serving apps at subdirectories.
# If galaxy should be served at subdirectory (e.g. example.com/galaxy) set nginx_galaxy_location: /galaxy
# If all apps should be served on a common subdirectory, use nginx_prefix_location: /your_common_dir
nginx_prefix_location: ""
nginx_galaxy_location: "{{ nginx_prefix_location }}"
nginx_reports_location: "{{ nginx_prefix_location }}/reports"
nginx_planemo_web_location: "{{ nginx_prefix_location }}/planemo"
nginx_ide_location: "{{ nginx_prefix_location }}/ide"

## Development Box Configuration
# Configure nginx to setup a proxy to an IDE.
nginx_proxy_ide: false
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- include: nginx.yml
when: galaxy_extras_config_nginx
tags: nginx_config

- include: proftpd.yml
when: galaxy_extras_config_proftpd
Expand Down
30 changes: 15 additions & 15 deletions templates/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ http {
{% if nginx_proxy_reports %}
# enable reports under :80/reports/
# if the file /etc/nginx/htpasswd exists authentification is enabled
location /reports/ {
location {{ nginx_reports_location }} {
set $auth "Galaxy reports are restricted. Please contact your administrator.";

if (!-f /etc/nginx/htpasswd) {
Expand All @@ -48,22 +48,22 @@ http {

auth_basic $auth;
auth_basic_user_file htpasswd;
proxy_pass http://127.0.0.1:{{ galaxy_reports_port }}/;
proxy_pass http://127.0.0.1:{{ galaxy_reports_port }};
}
# serve static content for report app
location /reports/static {
location {{ nginx_reports_location }}/static {
alias /galaxy-central/static;
gzip on;
gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
expires 24h;
}
location /reports/static/style {
location {{ nginx_reports_location }}/static/style {
alias /galaxy-central/static/style/blue;
gzip on;
gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
expires 24h;
}
location /reports/static/scripts {
location {{ nginx_reports_location }}/static/scripts {
alias /galaxy-central/static/scripts/packed;
gzip on;
gzip_types text/plain text/javascript application/x-javascript;
Expand All @@ -86,39 +86,39 @@ http {
include {{ nginx_conf_directory }}/{{ a }}.conf;
{% endfor %}
{% if nginx_serve_planemo_machine_web %}
location /planemo {
location {{ nginx_planemo_web_location }} {
alias {{ planemo_machine_web_dir }};
}
{% endif %}

# serve static content
location /static {
location {{ nginx_galaxy_location }}/static {
alias {{ galaxy_server_dir }}/static;
gzip on;
gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
expires 24h;
}
location /static/style {
location {{ nginx_galaxy_location }}/static/style {
alias {{ galaxy_server_dir }}/static/style/blue;
gzip on;
gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
expires 24h;
}
location /static/scripts {
location {{ nginx_galaxy_location }}/static/scripts {
alias {{ galaxy_server_dir }}/static/scripts/packed;
gzip on;
gzip_types text/plain text/javascript application/x-javascript;
expires 24h;
}

# delegated downloads
location /_x_accel_redirect {
location {{ nginx_galaxy_location }}/_x_accel_redirect {
internal;
alias /;
}

# this is needed if 'welcome_url' is set to /etc/galaxy/web
location /etc/galaxy/web {
location {{ nginx_galaxy_location }}/etc/galaxy/web {
alias /etc/galaxy/web;
gzip on;
gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
Expand All @@ -135,7 +135,7 @@ http {

{% if galaxy_extras_config_nginx_upload == True %}
# delegated uploads
location /_upload {
location {{ nginx_galaxy_location }}/_upload {
upload_store {{ nginx_upload_store_path }};
upload_store_access user:rw;
upload_pass_form_field "";
Expand All @@ -146,16 +146,16 @@ http {
upload_pass_args on;
upload_pass /_upload_done;
}
location /_upload_done {
location {{ nginx_galaxy_location }}/_upload_done {
set $dst /api/tools;
if ($args ~ nginx_redir=([^&]+)) {
set $dst $1;
}
rewrite "" $dst;
}
{% endif %}
error_page 502 /502.html;
location = /502.html {
error_page 502 {{ nginx_prefix_location }}/502.html;
location = {{ nginx_prefix_location }}/502.html {
root /root/;
proxy_intercept_errors on;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx_galaxy_web.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pass to uWSGI by default
location / {
location {{ nginx_galaxy_location }}/ {
proxy_pass http://galaxy_web_app;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx_ide.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
location /ide {
location {{ nginx_ide_location }} {
rewrite /ide/(.*) /$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx_uwsgi.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pass to uWSGI by default
location / {
location {{ nginx_galaxy_location }}/ {
uwsgi_pass 127.0.0.1:{{ uwsgi_port }};
include uwsgi_params;
{% if galaxy_admin_user is defined and galaxy_admin_user %}
Expand Down

0 comments on commit 7730cdb

Please sign in to comment.