MRatWork Forum by Mustafa Ramadhan

Sawo Project - Kloxo-MR Discussions => Kloxo-MR Technical Helps => Topic started by: Mansoor on 2019-08-09, 08:38:08

Title: How to redirect subdomain to specific port without changing url
Post by: Mansoor on 2019-08-09, 08:38:08
Hi
I have a centos 6.9 server with kloxo-mr7 installed and everything works like a charm but i have a problem, i have a service on port 660 and my senior said it has to be loaded on sub.domain.com without need of entering port number (if anybody enter sub.domain.com data should be loaded from myserver:660 without changing address bar url to 660 port)

what i did till now:
made sub.domain.com from kloxo panel
searched couple of days to find the solution and everywhere people suggested to setup in apache virtualhost but i couldn't find it anywhere in server (config files which includes virtualhost)

thanks for your kind help in advance
Title: Re: How to redirect subdomain to specific port without changing url
Post by: MRatWork on 2019-08-09, 09:09:07
Maybe need 'proxy' feature like nginx-proxy. In nginx-proxy, nginx listen port 80 and communicate to apache with port 30080 (default by Kloxo-MR).

Another alternative with using mod_proxy in apache.
Title: Re: How to redirect subdomain to specific port without changing url
Post by: Mansoor on 2019-08-09, 09:24:20
I'm on apache right now and since i can't change webserver at this point (several scripts are up and configured & i can't take risk of losing any of them) i think using apache method would be the best but i couldn't find a way to do so.

found this solution but i don't know where shoud i enter this, because httpd.conf doesn't look like what i've seen till now and also there are 3 different httpd.conf files in server in different paths:
Code: [Select]
<VirtualHost *:80>
    ServerAdmin me@mydomain.com
    ServerName dev.mydomain.com
    ProxyPreserveHost On

    # setup the proxy
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>
    ProxyPass / http://localhost:660/
    ProxyPassReverse / http://localhost:660/
</VirtualHost>
Title: Re: How to redirect subdomain to specific port without changing url
Post by: MRatWork on 2019-08-09, 09:45:46
Create subdomain for this purpose. And then copy '/opt/configs/apache/conf/domains/<subdomain>.conf' to '/opt/configs/apache/conf/customs/<subdomain>.conf'. Modified '<subdomain>.conf' inside this customs dir.

Modified content inside '<VirtualHost></VirtualHost>' under '## web for'. After that, run 'sh /script/fixweb; sh /script/restart-web'.

Note:
- make sure to choose 'proxy_fcgi_event' for 'PHP Type (for Apache)' in 'Webserver configure'.
- Modified '<IfVersion >= 2.4><IfModule mod_proxy_fcgi.c></IfModule></IfVersion>'
Title: Re: How to redirect subdomain to specific port without changing url
Post by: Mansoor on 2019-08-09, 10:03:34
Thanks for your kind help and really sorry for my childish kind questions, i didn't take a nap drom couple of nights that's why maybe i ask some stupid questions.
this is my proxy block code in virtualhost:

Code: [Select]
<IfVersion >= 2.4>
                <IfModule mod_proxy_fcgi.c>
                        ProxyRequests Off
                        ProxyErrorOverride On
                        ProxyPass /error !
                        ErrorDocument 500 /error/500.html
                        <Proxy "unix:/opt/configs/php-fpm/sock/php-apache.sock|fcgi://localhost">
                                ProxySet timeout=300
                                ProxySet connectiontimeout=300
                                # need disablereuse=on for 'ondemand'
                                ProxySet disablereuse=on
                                ProxySet max=25
                                ProxySet retry=0
                        </Proxy>
                        <FilesMatch \.php$>
                                SetHandler proxy:fcgi://localhost
                        </FilesMatch>
                </IfModule>
        </IfVersion>

may you help me to do my changes in file?

what i need is:
sub.domain.tld to be pointed to myserver:660 without changing url in addressbar

thanks agin for your kind help
Title: Re: How to redirect subdomain to specific port without changing url
Post by: MRatWork on 2019-08-09, 10:15:54
Try:
Code: [Select]
<IfVersion >= 2.4>
#<IfModule mod_proxy_http.c>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:660/
ProxyPassReverse / http://localhost:660/
#</IfModule>
</IfVersion>
Title: Re: How to redirect subdomain to specific port without changing url
Post by: Mansoor on 2019-08-09, 10:30:10
thanks again, i made the changes but it doesn't made any change in subdomain behaviour
maybe i made a mistake in copying file & path
i've did like this:

Code: [Select]
cp /opt/configs/apache/conf/domains/sub.domain.com.conf /opt/configs/apache/conf/customs/sub.domain.com.conf.Modified
is it correct or i misunderstood and did it in a wrong way?

one more thing, there is no "proxy_fcgi_event" in server php settings, i've selected "fcgid_event"
Title: Re: How to redirect subdomain to specific port without changing url
Post by: MRatWork on 2019-08-09, 14:33:27
Inform here 'sh /script/sysinfo'.
Title: Re: How to redirect subdomain to specific port without changing url
Post by: Mansoor on 2019-08-11, 12:52:34
sadly couldn't do the job at that time through your way so i did that using rewrite mode on .htaccess file.
thanks for your help anyway.