0
Not a bug

Web links URL domain issue, NGINX/OpenResty

Evan Trowbridge 5 years ago updated by Vlad R 5 years ago 12

I am having an issue when i go to share a folder as a link i can open the folder but when i click on the file in the folder it cuts off my domain. The current address is http://cloud.trowlink.com:8080/wl/?id=ljo0rCSfz..... it is cutting it to http://cloud.tro/wl/?id=ljo0rCSfz...... with out a port number. 


I have it as a sub domain with nginx.

Answer

Answer
Not a bug

If your server is configured with PHP correctly, there is no need for setting:

$config['url']['root'] = 'http://.....';

I recommend using this page as reference for configuring PHP with NGINX, paying particular attention to the NOTES section:

https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/

Under review

Can you provide a working sample link?

here is a test folder shared by a like when you click on the link it will open the folder. But the image previews don't work and when you click on a file inside of the folder it will not work http://cloud.trowlink.com:8080/wl/?id=yF7L2ElaU7i98sktPiMK25laEMGiJkX5

Is the FileRun installation behind a reverse proxy?

Even if not, I tend to believe there is a web server configuration problem, not filling the PHP environmental variables correctly. Even higher chances given that you are using a less common option (openresty).

Can't say more this problem without remote access to the server.

I am surprised that the FileRun login page works under these conditions. Have you manually created a config file inside FileRun?

I would look into:


$_SERVER['SCRIPT_NAME']

To make sure it is handled properly by your webserver/PHP-FPM configuration.

I have it setup as a sub domain in nginx with it pointing to the FileRun directory not a reverse proxy. OpenResty is basically nginx with a the ability to run lua scripts.



------------------------- Here is my openresty(nginx) virtual server config --------------------------


server {
    listen 8080;
    server_name cloud.trowlink.net cloud.trowlink.com;


    root /var/www/html/filerun;

    index index.php;


    ### If you changed the maximum upload size in PHP.ini, also change it below
    client_max_body_size 16G;
    # Prevent Clickjacking


    add_header X-Frame-Options "SAMEORIGIN";
    add_header Strict-Transport-Security "max-age=16070400; includeSubdomains";
    keepalive_requests 10;
    keepalive_timeout 60 60;
    access_log /var/log/nginx/access_pydio7.log;
    error_log /var/log/nginx/error_pydio7.log;
    client_body_buffer_size 128k;


    # Forward PHP so that it can be executed
    location ~ \.php$ {
            fastcgi_param GATEWAY_INTERFACE CGI/1.1;
            fastcgi_param SERVER_SOFTWARE nginx;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_param REQUEST_URI $request_uri;
            fastcgi_param DOCUMENT_URI $document_uri;
            fastcgi_param DOCUMENT_ROOT $document_root;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param REMOTE_ADDR $remote_addr;
            fastcgi_param REMOTE_PORT $remote_port;
            fastcgi_param SERVER_ADDR $server_addr;
            fastcgi_param SERVER_PORT $server_port;
            fastcgi_param SERVER_NAME $server_name;
            try_files $uri =404;
            fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    }
}


------------------------- Here is my  customizables/config.php ------------------------------------


<?php
$config['url']['root'] = 'http://cloud.trowlink.com:8080';
$config['app']['api']['oauth2']['allow_over_http'] = true;
$config['app']['ui']['enable_favicon_ico'] = true;  



I have even tried it with Apache it still has the same issue

$_SERVER['SCRIPT_NAME'];


outputs: /info.php

Answer
Not a bug

If your server is configured with PHP correctly, there is no need for setting:

$config['url']['root'] = 'http://.....';

I recommend using this page as reference for configuring PHP with NGINX, paying particular attention to the NOTES section:

https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/

I was able to fix it by adding a sub_filter to my openresty config


sub_filter http://cloud.tro/ http://cloud.trowlink.com:8080/;

sub_filter_once off;


It's a workaround though. Must be a better solution.

I can't find any PHP server variable that output http://cloud.tro/ instead of http://cloud.trowlink.com:8080/. so I am thinking that it is a FileRun issue. The work around works fine for me.

I am not completely excluding the possibility of being a FileRun bug. We would like to make sure of it. Could you contact us via e-mail and provide FTP access to the FileRun installation? We could then troubleshoot this and find out exactly what the problem is.