# using nginx to do reverse proxying for firefly web interface



## digrouz (Dec 27, 2011)

Hello,

I've installed from the ports and configured individually successfully both *nginx *and *firefly*. I'm now trying to do reverse proxying of the firefly web interface through nginx and I'm receiving xml-rpc errors in /var/log/mt-daapd.log and the pages are incomplete:



```
2011-12-27 09:38:06 (f2898dc3): Firefly Version svn-1696: Starting with debuglevel 5
2011-12-27 09:38:06 (f2898dc3): Loaded plugin /usr/local/lib/mt-daapd/plugins/out-daap.so (daap/svn-1696)
2011-12-27 09:38:06 (f2898dc3): Loaded plugin /usr/local/lib/mt-daapd/plugins/ssc-script.so (ssc-script/svn-1696)
2011-12-27 09:38:06 (f2898dc3): Loaded plugin /usr/local/lib/mt-daapd/plugins/rsp.so (rsp/svn-1696)
2011-12-27 09:38:06 (f2898dc3): Plugin loaded: rsp/svn-1696
2011-12-27 09:38:06 (f2898dc3): Plugin loaded: ssc-script/svn-1696
2011-12-27 09:38:06 (f2898dc3): Plugin loaded: daap/svn-1696
2011-12-27 09:38:06 (f2898dc3): Starting rendezvous daemon
2011-12-27 09:38:06 (f2898dc3): Starting signal handler
2011-12-27 09:38:06 (f2898dc3): Initializing database
2011-12-27 09:38:06 (f2898dc3): Starting web server from /usr/local/share/mt-daapd/admin-root on port 3689
2011-12-27 09:38:06 (f2898dc3): Listening on port 3689
2011-12-27 09:38:06 (f2898dc3): Starting server thread
2011-12-27 09:38:06 (f2898dc3): Registering rendezvous names
2011-12-27 09:38:06 (f2898dc3): Serving 1 songs.  Startup complete in 1 seconds
2011-12-27 09:39:40 (4d30a9d4): Thread 10: Error opening /usr/local/share/mt-daapd/admin-root/xml-rpc: No such file or directory
2011-12-27 09:39:40 (4d30a9d4): Thread 10: Entering ws_returnerror (404: Not found)
```

Here is my /usr/local/etc/nginx/nginx.conf file:

```
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    client_max_body_size 128M;
    keepalive_timeout  65;
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    client_body_buffer_size 128k;
    client_header_buffer_size 64k;
    proxy_connect_timeout   90;
    proxy_send_timeout      90;
    proxy_read_timeout      90;
    proxy_buffer_size   16k;
    proxy_buffers       32   16k;
    proxy_busy_buffers_size 64k;


    server {
        listen       80;
        server_name  www.my.domain;

        location /phpMyAdmin {
                root /usr/local/www;
                index index.php;
        }
        
        location ~ ^/phpMyAdmin.+\.php$ {
                root /usr/local/www;
                include fastcgi_params;
        }

        location ~ ^/phpMyAdmin.+\.(js|css|png|jpg|jpeg|gif|ico)$ {
                root /usr/local/www;
                expires max;
                log_not_found off;
        }

        location /phpmyadmin {
                rewrite ^/* /phpMyAdmin last;
        }

        location /mediawiki {
                if (!-e $request_filename) {
                        rewrite ^/mediawiki/([^?]*)(?:\?(.*))? /mediawiki/index.php?title=$1&$2 last;
                }
                root /usr/local/www;
                index index.php;
        }

        location ~ ^/mediawiki.+\.php$ {
                root /usr/local/www;
                include fastcgi_params;
        }

        location ~ ^/mediawiki.+\.(js|css|png|jpg|jpeg|gif|ico)$ {
                root /usr/local/www;
                expires max;
                log_not_found off;
        }


        location /wiki {
                rewrite ^/* /mediawiki last;
        }


        location /wordpress {
                root /usr/local/www;
                try_files $uri $uri/ /wordpress/index.php;
                index index.php;
        }

        location = / {
                rewrite ^/* /wordpress last;
        }


        location ~ ^/wordpress.+\.php$ {
                root /usr/local/www;
                include fastcgi_params;
        }

        location ~ ^/wordpress.+\.(js|css|png|jpg|jpeg|gif|ico)$ {
                root /usr/local/www;
                expires max;
                log_not_found off;
        }


        location /blog {
                rewrite ^/* /wordpress last;
        }

        # BEGIN W3TC Browser Cache
        gzip on;
        gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location ~ ^/wordpress.+\.(css|js|htc)$ {
                expires 31536000s;
                add_header Pragma "public";
                add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
                add_header X-Powered-By "W3 Total Cache/0.9.2.4";
        }
        location ~ ^/wordpress.+\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
                expires 3600s;
                add_header Pragma "public";
                add_header Cache-Control "max-age=3600, public, must-revalidate, proxy-revalidate";
                add_header X-Powered-By "W3 Total Cache/0.9.2.4";
        }
        location ~ ^/wordpress.+\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|
mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|
xla|xls|xlsx|xlt|xlw|zip)$
 {
                expires 31536000s;
                add_header Pragma "public";
                add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
                add_header X-Powered-By "W3 Total Cache/0.9.2.4";
        }
        # END W3TC Browser Cache
        # BEGIN W3TC Minify core
        rewrite ^/wordpress/wp-content/w3tc/min/w3tc_rewrite_test$ /wordpress/wp-content/w3tc/min/index.php?w3tc_rewrite_test=1 last;
        rewrite ^/wordpress/wp-content/w3tc/min/(.+\.(css|js))$ /wordpress/wp-content/w3tc/min/index.php?file=$1 last;
        # END W3TC Minify core
        
        location /phpBB3 {
                root /usr/local/www;
                index index.php;
        }

        # Deny access to internal phpbb files.
        location ~ ^/phpBB3/(config\.php|common\.php|includes|cache|files|store|images/avatars/upload){
                root /usr/local/www;
                deny all;
                internal;
        }

        location ~ ^/phpBB3.+\.php$ {
                root /usr/local/www;
                include fastcgi_params;
        }

        location ~ ^/phpBB3.+\.(js|css|png|jpg|jpeg|gif|ico)$ {
                root /usr/local/www;
                expires max;
                log_not_found off;
        }

        location /phpBB {
                rewrite ^/* /phpBB3 last;
        }

        location /transmission {
            proxy_pass      http://127.0.0.1:9091/transmission;
            auth_basic "Transmission authentication";
            auth_basic_user_file /usr/local/etc/nginx/nasusers.htpasswd;
        }

        location /firefly {
            proxy_pass      http://127.0.0.1:3689/;
            proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect   http://127.0.0.1:3689/      /firefly/;
        }

        location / {
            try_files $uri $uri/ /index.php;
            root   /usr/local/www/data;
            index  index.php index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /usr/local/www/nginx-dist;
        }

        location ~ \.php$ {
            root /usr/local/www/data;
            fastcgi_intercept_errors on;
            error_page 404 /error/404.php;
            include fastcgi_params;
        }

        location ~ /\.ht {
            deny  all;
        }
  }
}
```

How to get the reverse proxy working correctly?


----------

