logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: redirect to same server but with additonal parameters in URL
Author
guthrie



Joined: 29 Jun 2019
Posts: 5
Location: usa, fairfield

PostPosted: Sun 26 May '24 23:20    Post subject: redirect to same server but with additonal parameters in URL Reply with quote

I have a cloud server site at a fixed IP address ("Site") and have a domain name "CS" that points to it. I did this just to isolate the public name (CS) from the current server (Site) used.
On that system I setup a server tool that is accessed by the URL: "CS:8000/index".
I created an additional domain name to hide those details, "TmR", and want to have TmR map to "CS:8000/index".
I then added a new virtual server on CS(=> Site) like this:
Code:
1.   <VirtualHost *:80>
2.     ServerName TmR.org
3.     Redirect / http://localhost:8000/index
4.    </VirtualHost>

was added to: /etc/apache2/sites-available/000-default.conf
Then in the DNS for TmR, I added a Cname pointing it to CS. It also has an A record, with the actual IP of Site (It is a leftover from initial setup, and I didn't know if that was needed, or...?)
Having both a Cname & an A record seem redundant.
Is this a right approach?
Using Tmr does not work, it just brings up the default web page on CS. Looks like the A record redirects, but Apache does not(?).
Using the full URL: "Tmr:8000/index" works.
But what I would think should be the same; CS:8000... or IP:8000... both fail, "404 bad request", which seems to come from the tool as the browser tab shows the icon of the tool (not Apache?)
Elsewhere I got the suggestion that I needed this, but they were directives I was not familiar with.
Code:
1.   <VirtualHost *:80>
2.     ServerName Tmr
3.     ProxyPreserveHost On
4.     ProxyPass / http://CS:8000/index
5.     ProxyPassReverse / http://CS:8000/index
6.    </VirtualHost>

When I added the proxy... directives, it did load the tool, but did not propagate the parameters (/index) with it, so it was mis-formatted and not able to load required helper pages under the specified (/index) root file name.

So I tried instead a redirect (again), with a URL propagate parameter:
Code:
        ## Redirect 308 / http://localhost:8000/index
      ## Redirect 308 / http://cs:8000/index
           Redirect 308 / Tmr:8000/index

None worked…
Any hints ???

With the 308 redirect,
Tmr → http://cs:8000/index
The URL’s
• http://cs:8000/index
• http://IP:8000/index
give a 400 error, I think perhaps because it cannot find the css file since the file location base parameter is lost?
Just entering the IP address, does convert to the full desired URL and it all works.
• http://IP → http://tmr:8000/index
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 325
Location: UK

PostPosted: Mon 27 May '24 16:24    Post subject: Reply with quote

In your post you say you set up the "TmR" site to hide the details of the CS site details, so believe you need to use proxy directives rather than redirects, else the browser will switch to CS based URLs.

However, you don't say whether the missing css (and other support files) are relative to the CS site root or below the index suffix you've specified. If they are below, then your proxypass paths will need to match, and you'll probably want a redirect from the site root to /index, e.g.
Code:

<VirtualHost *:80>
     ServerName Tmr
     Redirect / /index
     ProxyPreserveHost On
     ProxyPass /index http://CS:8000/index
     ProxyPassReverse /index http://CS:8000/index
<VirtualHost>

Also, make sure all your local css, image, script and other support files referenced by your HTML code are site relative.
Back to top
guthrie



Joined: 29 Jun 2019
Posts: 5
Location: usa, fairfield

PostPosted: Tue 28 May '24 5:00    Post subject: DNS/Apache URL rewriting Reply with quote

Thank you for the note and reply.
If I run this:
Tmr:8000/index
it works fine, as before.
but just running Tmr (with your setup)
converts it to:
CS:8000/Index
which gives a 404 error, although the browser tab shows the Tmr app icon (I don't know how that is set).
(I simplified the actual URL which is:
http://Tmr:8000/index.php/ojs-files/index )
Back to top
guthrie



Joined: 29 Jun 2019
Posts: 5
Location: usa, fairfield

PostPosted: Tue 28 May '24 5:24    Post subject: Reply with quote

Hmm,
plain: tmr
fails, but running tmr:8000
resolves fine and runs
It resolves to tmr:8000/Index...
which has always been working.
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 325
Location: UK

PostPosted: Tue 28 May '24 11:13    Post subject: Reply with quote

There's not enough detail here to work out exactly what's going on.

Suggest you use Developer Tools in your browser (Ctrl+Shift+I) to check on exactly what Request/Response Headers are occurring, along with the Response Body, and from that determine what changes are needed to your Apache configuration and site content.
Back to top
guthrie



Joined: 29 Jun 2019
Posts: 5
Location: usa, fairfield

PostPosted: Tue 28 May '24 14:46    Post subject: Reply with quote

ok.
Also, for example, the direct IP, gives an non-terminating redirect...
It should just get the standard :80 welcome web page, as should /CS alone.
159... -> 159..../indexindexindexindexindex...
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 325
Location: UK

PostPosted: Tue 28 May '24 17:29    Post subject: Reply with quote

So is /index a folder or a file? If a file is your site entry point index.html or index.php (a previous post suggested index.php was a folder:- http://Tmr:8000/index.php/ojs-files/index)?

If /index is a folder, then change the redirect to match, e.g. /index/

If your entry point is index.php, have you updated the DirectoryIndex entry to include index.php?

If you're still stuck, suggest you post your configuration (anonymized) to pastebin along with an overview of your site content layout, so people may be able to help you further.
Back to top
guthrie



Joined: 29 Jun 2019
Posts: 5
Location: usa, fairfield

PostPosted: Wed 29 May '24 0:38    Post subject: Reply with quote

Thank you.
I think that index is a file - but since this system runs on a php web-server (:8000) I don't know the details of how that works, or is configured.
I think the Apache URL (Tmr:80) is supposed to hand off the request to the PHP server (:8000/Index (=Params)), which is configured for it's own "index" file configuration.
If I can just get that redirection setup, then I don't need to know how the self-contained php server and setup works.
And as noted, if I give the full URL to it directly it does work find, so I am just fighting with Apache to do the remapping of the URL.
I'll research further.
Back to top


Reply to topic   Topic: redirect to same server but with additonal parameters in URL View previous topic :: View next topic
Post new topic   Forum Index -> Apache