Proxying Galaxy with Apache httpd Rewrite?

admin
apache
proxy

#1

I was setting up Apache using the instructions in the link. https://docs.galaxyproject.org/en/master/admin/apache.html#serving-galaxy-at-the-web-server-root
However, my sysadmin said that it does not work the way the site said.

When you use the RewriteRule:

RewriteRule Pattern Substitution

both Pattern and Substitution are supposed to be URL paths. But you
were using a filesystem path (/peopleroot/…). That’s why it couldn’t
be found.

What you want there is an Alias. I added the following to your config:

Alias “/static” “/peopleroot/skim/galaxy/static”
Alias “/static/style” “/peopleroot/skim/galaxy/static/style/blue”
Alias “/favicon.ico” “/peopleroot/skim/galaxy/static/favicon.ico”
Alias “/robots.txt” “/peopleroot/skim/galaxy/static/robots.txt”
Alias “/plugins” “/peopleroot/skim/galaxy/config/plugins”

See:

https://server.mb.re.kr/favicon.ico
https://server.mb.re.kr/plugins/visualizations/scatterplot/static/logo.png

However, some URLs:

https://server.mb.re.kr/plugins/visualizations/scatterplot/static/scatterplot.css

return a 404 with the message, “This link may not be followed from
within Galaxy.”

Galaxy source code says the error is “Called on any url that does not
match a controller method”.

I’m not sure what that’s about, but I found this discussion:

https://biostar.usegalaxy.org/p/518/

Is it possible to know what is the correct way to do this?
Now the favicon.ico works, but the main website does not load…

Current httpd conf for :443
#
# This configuration file is for HTTPS (port 443).
#
#
# IMPORTANT: Run this as root after making any changes:
#
# /usr/local/psa/admin/bin/httpdmng --reconfigure-domain server.mb.re.kr
#

# use a variable for convenience
# NB: mod_define is only for Apache 2.4+.
#Define galaxy_root /peopleroot/skim/galaxy

#
# set up for proxies
#
ProxyRequests Off
SetOutputFilter proxy-html
SSLProxyEngine On
# don't decode encoded slashes in path info
AllowEncodedSlashes On

# enable compression on all relevant types
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/json

# allow access to static content
Alias "/static" "/peopleroot/skim/galaxy/static"
<Directory "/peopleroot/skim/galaxy/static">
    AllowOverride None
    Require all granted
</Directory>
Alias "/static/style" "/peopleroot/skim/galaxy/static/style/blue"
Alias "/favicon.ico" "/peopleroot/skim/galaxy/static/favicon.ico"
Alias "/robots.txt" "/peopleroot/skim/galaxy/static/robots.txt"

# Galaxy needs to know that this is https for generating URLs
RequestHeader set X-URL-SCHEME "%{REQUEST_SCHEME}e"

# allow up to 6 minutes for Galaxy to respond to slow requests before timing out
ProxyTimeout 360

# or uWSGI on a TCP socket
ProxyPass / uwsgi://127.0.0.1:4432/ nocanon

# serve framework static content
#RewriteEngine On
# THE FOLLOWING IS WRONG:
#RewriteRule ^/static/style/(.*) /peopleroot/skim/galaxy/static/style/blue/$1 [L]
#RewriteRule ^/static/(.*) /peopleroot/skim/galaxy/static/$1 [L]
#RewriteRule ^/favicon.ico /peopleroot/skim/galaxy/static/favicon.ico [L]
#RewriteRule ^/robots.txt /peopleroot/skim/galaxy/static/robots.txt [L]

# enable caching on static content
<Location "/static">
    ExpiresActive On
    ExpiresDefault "access plus 24 hours"
</Location>

Alias "/plugins" "/peopleroot/skim/galaxy/config/plugins"
<Directory "/peopleroot/skim/galaxy/config/plugins">
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

# serve visualization and interactive environment plugin static content
<Directory "/peopleroot/skim/galaxy/config/plugins/(.+)/(.+)/static">
    AllowOverride None
    Require all granted
</Directory>
# THE FOLLOWING IS WRONG:
#RewriteRule ^/plugins/(.+)/(.+)/static/(.*)$ /peopleroot/skim/galaxy/config/plugins/$1/$2/static/$3 [L]

#2

No Apache expert here, but the documentation of Apache clearly states

The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.

So I think the galaxy documentation is correct.