apioo / fusio

Open source API management platform

Home Page:https://www.fusio-project.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redirects to :port

theraw opened this issue Β· comments

Hello,
so i've installed fusio inside a container on port 8030 no ssl, and while i try to open other pages then / example
https://api.example.net/apps/ it sends me to https://api.example.net:8030/apps/

now my domain is under a reverse proxy that is pointed to container.ip:port

i was checking out my reverse proxy configs but i don't see anything weird :/
do you have any idea if theres some php code that is redirecting it to the containers port?

my server_port is 8030 at php env

[SERVER_PORT] => 8030

you may ask why not use port 80 on container, well that would end on a infinite loop since my reverse proxy will redirect http to https and php will redirect 443 to 80
thank you

Hi @theraw Iam not sure whether the redirect is actually triggered by Fusio, but you could check whether the FUSIO_URLat the.env` file contains the correct url without port. Otherwise there should be not problem to use a different port, if you have a reverse proxy you also dont need to add the port to the url.

.env

FUSIO_PROJECT_KEY="xxxxxxxxxxxxxxxxxxxxxxxxx"
FUSIO_HOST="api.dopehosting.net"
FUSIO_URL="https://api.dopehosting.net"
FUSIO_APPS_URL="https://api.dopehosting.net/apps"
FUSIO_ENV="prod"
FUSIO_DB_NAME="xxxx"
FUSIO_DB_USER="xxx"
FUSIO_DB_PW="xxxxxxxxxxx"
FUSIO_DB_HOST="xxxxxxxxxxxxxxxxxxs"
FUSIO_DB_DRIVER="pdo_mysql"
FUSIO_MAILER="native://default"
FUSIO_MAIL_SENDER=""
FUSIO_PHP_SANDBOX="off"
FUSIO_MARKETPLACE="off"

(localhost inside container)
vhost config

server {
        listen 8030;
        index index.php index.html;
        root /home/container/public_html/fusio/public;

        server_name api.dopehosting.net;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        access_log /home/container/log/public_html.log;
        include    /home/container/config/php.conf;
}

php.conf

location ~ \.php {
  try_files $uri $uri /index.php =404;
  fastcgi_pass 127.0.0.1:9082;
  fastcgi_buffers 16 256k;
  fastcgi_buffer_size 256k;
  fastcgi_index index.php;
  fastcgi_read_timeout 90;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
}

nginx.conf

worker_processes     auto;
worker_rlimit_nofile 655350;
pcre_jit             on;
# ====================================================================
error_log             off;
pid                   /home/container/tmp/nginx.pid;
# ====================================================================
# ====================================================================
events {
    worker_connections 65535;
    multi_accept on;
}
# ====================================================================
http {
        include                       /etc/nginx/mime.types;
        default_type                  application/octet-stream;
        sendfile                      on;
        server_tokens                 off;
        tcp_nopush                    on;
        tcp_nodelay                   on;
        http2_push_preload            on;
        keepalive_timeout             90s;
        keepalive_requests            100;
        client_body_buffer_size       10M;
        client_header_buffer_size     10M;
        client_max_body_size          1000M;
        large_client_header_buffers 4 256k;
        client_body_timeout           90s;
        client_header_timeout         90s;
        send_timeout                  90;
        server_names_hash_bucket_size 1024;
        log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
        # Dynamically generated resolvers file
        resolver 1.1.1.1 1.1.0.0  valid=10s;
        # Default upstream scheme
        map $host $forward_scheme {
                default http;
        }
        map $http_upgrade $connection_upgrade {
                default upgrade;
                '' close;
        }
        set_real_ip_from 10.0.0.0/8;
        set_real_ip_from 172.16.0.0/12; # Includes Docker subnet
        set_real_ip_from 192.168.0.0/16;
        include /etc/nginx/config/ip_ranges.conf;
        real_ip_header          X-Forwarded-For;
        real_ip_recursive       on;
        include /home/container/config/*.vhost;
        client_body_temp_path          /home/container/tmp/body 1 2;
        proxy_temp_path                /home/container/tmp/proxy;
        fastcgi_temp_path              /home/container/tmp/fastcgi;
        uwsgi_temp_path                /home/container/tmp/uwsgi;
        scgi_temp_path                 /home/container/tmp/scgi;
        error_log                      off;
        access_log                     off;
        gzip on;
        gzip_buffers 16 8k;
        gzip_comp_level 5;
        gzip_disable "msie6";
        gzip_min_length 256;
        gzip_proxied any;
        gzip_types
            application/atom+xml
            application/javascript
            application/json
            application/ld+json
            application/manifest+json
            application/rss+xml
            application/vnd.geo+json
            application/vnd.ms-fontobject
            application/x-font-ttf
            application/x-javascript
            application/x-web-app-manifest+json
            application/xhtml+xml
            application/xml
            font/opentype
            image/bmp
            image/svg+xml
            image/x-icon
            text/cache-manifest
            text/css
            text/javascript
            text/plain
            text/vcard
            text/vnd.rim.location.xloc
            text/vtt
            text/x-component
            text/x-cross-domain-policy
            text/x-js
            text/xml;
        gzip_vary on;
}

i'm not posting my reverse proxy domain config because i don't think thats important, i tried to run it on another container with cloudflare subdomains (https://try.cloudflare.com/) and entering / is good then i try /apps it redirects to :port/apps/

aa4ba7ab-06d2-4abb-b6a4-2a1d9354fc94:~/config$ curl -s -v 'https://api.dopehosting.net/apps'
> GET /apps HTTP/2
> Host: api.dopehosting.net
> user-agent: curl/8.0.1
> accept: */*
>
< HTTP/2 301
< date: Wed, 03 May 2023 17:15:54 GMT
< content-type: text/html
< content-length: 162
< location: http://api.dopehosting.net:8030/apps/
< x-served-by: api.dopehosting.net

(just noticed it also tries to send me to http)

didn't want to waste cpu time on encrypting traffic from server to container so i was trying this setup.
since don't seem to work i'll setup proper ssl for now. closing the issue but if there's some way to fix it would like to hear

thanks