[nycbug-talk] OT: Apache/mod_rewrite question

Kevin Reiter tux at penguinnetwerx.net
Tue Jan 30 22:35:00 EST 2007


Dan Langille wrote:
> On 30 Jan 2007 at 9:14, Kevin Reiter wrote:
> 
>> -----Original Message-----
>> From: talk-bounces at lists.nycbug.org
>> [mailto:talk-bounces at lists.nycbug.org]On Behalf Of Dan Langille
>> Sent: Tuesday, January 30, 2007 7:34 AM
>> To: Kevin Reiter
>> Cc: talk at lists.nycbug.org
>> Subject: Re: [nycbug-talk] OT: Apache/mod_rewrite question
>>
>>
>> On 30 Jan 2007 at 1:02, Kevin Reiter wrote:
>>
>>> Dan Langille wrote:
>>>> On 28 Jan 2007 at 23:09, Kevin Reiter wrote:
>>>>
>>>>> Kevin Reiter wrote:
>>>>>> Jonathan Stewart wrote:
>>>>>>> Kevin Reiter wrote:
>>>>>>>> All,
>>>>>>>>
>>>>>>>> I've been trying to figure this out for a few hours now, and I
>>>>>>>> can't quite get it working, and I *know* someone in here knows
>>>>>>>> how to do this...
>>>>>>>>
>>>>>>>> I'm trying to force all traffic to an Apache server (on my
>>>>>>>> laptop) to use SSL.  The laptop is on a dynamic IP with no
>>>>>>>> static domain, so I can't force http://machine.domain.tld to
>>>>>>>> https://machine.domain.tld, and since the IP changes depending
>>>>>>>> on where I am, I can't use that for a rewrite, either.
>>>>>>>>
>>>>>>>> Do any of you Apache gurus know of a way to do this using an
>>>>>>>> .htaccess file or via a simple edit to httpd.conf?  I've been
>>>>>>>> checking Google for awhile, but everything I've come across
>>>>>>>> doesn't quite do the trick.
>>>>>>> Not exactly what your asking about but have you considered
>>>>>>> using a dynamic DNS service?  I use No-IP () and have been very
>>>>>>> happy with them.  They even manually setup IPv6 records for me
>>>>>>> even though they are not technically supported.  Although I am
>>>>>>> paying for a domain name and dns they provide free sub-domains
>>>>>>> as well. If thats not an option I'll see what I can do about a
>>>>>>> rewrite rule for you.
>>>>>>>
>>>>>>> Jonathan
>>>>>> This is for a traveling laptop that I use both at home and at
>>>>>> client sites, and as a test machine at my new job, so I don't
>>>>>> always have the same IP, which is how I typically access the
>>>>>> server.
>>>>>>
>>>>>> I should've mentioned that I know about zero when it comes to
>>>>>> writing rewrite rules (this would be a first).
>>>>>>
>>>>>> In this case, a dynamic DNS service would do nothing for me
>>>>>> (I've had a paid account with FreeDNS[1] for years now.)
>>>>>>
>>>>>> Basically, I'm looking to force the use of SSL on my webserver
>>>>>> (apache+mod_ssl-1.3.37+2.8.28) when the IP and domain are always
>>>>>> changing.
>>>>>>
>>>>>> I recall seeing something about {SERVER_ADDR} as a variable,
>>>>>> which would be exactly what I'm looking for, but I don't have a
>>>>>> clue outside of that what to write in the .htaccess file.
>>>>>>
>>>>> Helps when I include the link..
>>>>>
>>>>> [1] http://freedns.afraid.org/
>>>> Does this help?  This is how I redirect http://papers.bsdcan.org
>>>> to https://papers.bsdcan.org
>>>>
>>>>
>>>> <VirtualHost 216.168.29.7>
>>>>     ServerAdmin dan at langille.org
>>>>     ServerName  papers.bsdcan.org
>>>>
>>>>     Redirect    permanent / https://papers.bsdcan.org/
>>>> </VirtualHost>
>>>>
>>>> I use similar methods to redirect http://freshports.org to 
>>>> http://www.freshports.org/
>>>>
>>>> hth
>>>>
>>> It would if I had a static IP, but since it changes multiple times a
>>> day, I don't think it'll fly for the laptop.  It will, however, be
>>> perfect for a few other machines I just setup at work - thanks, Dan!
>> Details... always with the details.
>>
>> Use a dynamic dns service so that hostnames are updated when the IP
>> address changes.  I use no-ip.com
>>
>> (I hate Outlook..)
>>
>> As I stated before, I can't use a DNS service because I'm connected to
>> client networks with an INSIDE IP, and it wouldn't do any good on a
>> LAN to have such a service in use for this particular instance.
>>
>> Thanks for the tip, though.  I'll be doing that here at work in a few
>> minutes on my other servers.
> 
> So... who will be accessing this website?  I think I asked this 
> before.  Just you?  Others?
> 
> If just you, just localhost, 127.0.0.1.
> 
> Of others, you're back to the DNS problem again...
> 

I'll be the only one accessing the webserver.  Usually, I access it via 
whatever IP the box has on whatever network I'm on, rather than by name 
(since internal DNS won't get the record added before I leave.)

I guess I was thinking that if I use the loopback address, I wouldn't be 
able to hit it outside the local machine.  Yeah, I know, so don't waste 
your breath telling me.  I must've got some real bad crack when I was 
thinking that :P

I'll give it a whirl tomorrow and see if that does the trick.



More information about the talk mailing list