archiveren

Tagarchief: php

Another story standing since November 2012 (lol 😀 ).
The only thing that has changed: ARR (read on) is now officially supported by Microsoft!
They’re even almost/perhaps/maybe/theoretical/optional considering it as a successor for TMG2010 😛

Anyway, this post is not entirely correct. What we were trying to do was reverse proxy to an sub-directory. That didn’t work…
But  you can get some feeling with the possibilities of IIS’s ARR .

3 days later, but I solved this terrible situation…

The story

Our current website http://www.smartsys.be runs on an asp-powered cms called “umbraco” (url).
So, that makes it needs IIS and MS SQL accordingly…

Second part of the story: we want to introduce a blog with our success stories!
Number one blog software of our choice: wordpress (ofcourse 🙂 )

But, as we all know, wordpress runs on php and not asp, and an accompanying database…

The options:

  1. install php/fastcgi on IIS, mess around with it’s config, use ms sql as backend db, and run everything in IIS…
  2. use apache for both reverse proxying and serving the wordpress pages
  3. let IIS serve our umbraco web pages and set it up as reverse proxy for apache!

So, in the end, we tried only both last options.
I didn’t actually want to try and install php in IIS and maybe mess up our actual web service…

The result

Apache as reverse proxy didn’t end very well…
Actually, it didn’t work at all…
No idea why, didn’t put much effort in it…

On the other hand, IIS as reverse proxy wasn’t easy as well…
It took almost 3 days to figure out what went wrong, how to avoid it from happening, and in the end: how to solve it!
note: not 3 full days, but “some time during 3 days” ^^

How!

So, a little how-to:

First of all, you need IIS, just enable the feature on your Windows or Windows Server.
Secondly, you need “Application Request Routing“. You can download and install this without taking down your website.
This module is officially supported by Microsoft!

So, when both are installed, you can start configuring…

Enable ARR for your site : select your server in IIS Manager, open Application Request Routing under IIS options, choose “Server Proxy Settings” from the actions tab, and mark “enable” and press apply.

Secondly, we can start reverse proxying!

Select your site, in our example the “default web site”, and open the “url rewrite” module.
Here is where the magic should happen!

You can easily add a new rule clicking “add rule(s)”. And in our case, we’re choosing for “reverse proxy”.

Next, choose the path for your destination server, in our case being “http://localhost:8080/test/” .
Also, in the case for wordpress (very important): enable outbound rules, these are the rewrite rules…

One of the main issues want took so long to understand was a redirection issue: wordpress itself tries to redirect your to its config page, and IIS trying to rewrite the request to the wordpress folder. Resulting in endless 301 redirections… So, watch out here!
At first, I believed I could fix it by changing the config in wordpress. And I took to long to try to fix it that way. In the end (and what we’re doing in this manual) letting IIS handle all this reverse proxy work does the job…

So after adding this rule, we need to correct it somehow.
The default settings are not really good enough (maybe in your case it is!)

So, let’s have a look at the Inbound rule. Just open it.
I’m going to change the “pattern” IIS filters on from “(.*)” to “^test/(.*)” . This makes only requests for “blog.smartsys.be/test/” to be accepted.

Secondly, you have to add {R:1} to the end of the “rewrite url”. Otherwise things as http://blog.smartsys.be/test/wordpress/wp-admin/index.php would never work. It’s just the argument from the initial request that’s forwarded to the rewritten url…

That’s it, apply and close, next we’ll have a look to the outbound rule.

So, the big problem with wordpress is something with redirection. So, in the end, I made it undectectable for wordpress it’s being reverse proxied. So, in wordpress its point of view, it’s just running on localhost:8080 .

This implies we need to rewrite localhost:8080 to something external available, in our case “blog.smartsys.be”…
This is where the “outbound rule” comes in!

I just modified some parts of the default configuration the “add reverse proxy” wizard from before created.

At first: match all content!
The pattern should be” ^http(s)?://localhost:8080/(.*)”
And action value becomes: “http://blog.smartsys.be/{R:2}”

So, I hope you don’t spend any time on trying to let wordpress fix it (because it won’t), just let IIS do all the work!

Advertenties

Tussen het leren van men analoge elektronica in ben ik bezig met een projectje om een database op te stellen van een aantal computers.

Het idee is om van een 2-tal locaties ten allen tijde het ip te kennen.
Nu kan je ofwel gebruik gaan maken van services zoals no-ip, welke heel goed werken. Heb het op men eigen pc ook draaien. Maar op sommige computers kan je principieel gewoon geen andere software installeren…

Dus maar zelf iets aan het maken geweest. Iets in deze stijl.
Alles gehost op de fantastische duitse webhost ohost.

De broncode is vrij gebaseerd op die uit men vorige post. Maar bij deze wordt het dus opgeslagen in een achterliggende mysql-database 🙂

Kan ik alles mooi bijhouden 🙂

Eerste tech-post.

Ik was dus op zoek naar een leuk tooltje om men extern ip-adres te krijgen.
Er zijn zoveel sites die dan aanbieden, maar ik wou dat gewoon zelf.

Dus ik in php beginnen rommelen.
En volgende code is er uitgekomen

$hostname = gethostbyaddr($_SERVER[‘REMOTE_ADDR’]);
Dit regeltje toont wat informatie over de isp die je gebruikt.

$ip = $_SERVER[‘REMOTE_ADDR’];
Je ip adres.

$agent = $_SERVER[‘HTTP_USER_AGENT’];
Welke browser, onder welk OS

$page = basename($_SERVER[‘REQUEST_URI’]);
Opgevraagde pagina.

Nu wou ik deze informatie laten doormailen met het php-functie “mail”. Maar die blijkt nog niet goed te werken…
Das voor straks, want nu eerst herexamens leren 🙂

Maar in alle geval, het resultaat van bovenstaande wordt dan iets in deze stijl.