# Proxying Galaxy with Apache httpd Rewrite?

**URL:** <https://help.galaxyproject.org/t/proxying-galaxy-with-apache-httpd-rewrite/505>\
**Category:** Uncategorized\
**Tags:** devops-administration, proxy\
**Created:** [January 24, 2019, 10:32am UTC](https://help.galaxyproject.org/t/proxying-galaxy-with-apache-httpd-rewrite/505 "2019-01-24T10:32:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skim](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@skim](https://help.galaxyproject.org/u/skim)\
**Post date:** [January 24, 2019, 10:32am UTC](https://help.galaxyproject.org/t/proxying-galaxy-with-apache-httpd-rewrite/505/1 "2019-01-24T10:32:36Z")

</div>

I was setting up Apache using the instructions in the link. [Proxying Galaxy with Apache — Galaxy Project 25.1.1.dev0 documentation](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/favicon.ico)  
> [https://server.mb.re.kr/plugins/visualizations/scatterplot/static/logo.png](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](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:
> 
> [Fresh Install Has Wrong Layout](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]

```

---

<div class="post-metadata">

**Author:** ![mvdbeek](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/mvdbeek/32/110_2.png) [@mvdbeek](https://help.galaxyproject.org/u/mvdbeek)\
**Post date:** [January 24, 2019, 10:37am UTC](https://help.galaxyproject.org/t/proxying-galaxy-with-apache-httpd-rewrite/505/2 "2019-01-24T10:37:05Z")

</div>

No Apache expert here, but the [documentation of Apache](https://httpd.apache.org/docs/current/mod/mod_rewrite.html) 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.
