# Apache not responding outside my network



## nbsjbsd (Jul 25, 2016)

Ok, so I have a strange one. I've got a FreeBSD 10.3 server running Apache 2.4. I ported my mediawiki over from an old Ubuntu server that I want to remove. Now, the Ubuntu server is still up and running and when I try and hit my wiki from outside my internal network, it works fine. However, when I swap over to my new FreeBSD server and I make the port forwarding changes on my ISP router, I can't get to the FreeBSD server. I've tried telnet to port 80 and I get no response either. The only message I see in my http_access.log is similar to this:

```
193.200.150.82 - - [25/Jul/2016:15:57:58 -0300] "GET / HTTP/1.0" 301 -
193.200.150.82 - - [25/Jul/2016:15:59:45 -0300] "GET / HTTP/1.0" 301 -
```
If I connect internally, I see this:

```
192.168.2.57 - - [25/Jul/2016:16:11:34 -0300] "GET /index.php/Main_Page HTTP/1.1" 304 -
192.168.2.57 - - [25/Jul/2016:16:11:34 -0300] "GET /load.php?debug=false&lang=en&modules=mediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.interface%7Cmediawiki.ui.button%7Cskins.vector.styles&only=styles&skin=vector&* HTTP/1.1" 304 -
192.168.2.57 - - [25/Jul/2016:16:11:34 -0300] "GET /load.php?debug=false&lang=en&modules=startup&only=scripts&skin=vector&* HTTP/1.1" 304 -
```
I see no errors in the http_error.log either.

Any thoughts folks?


----------



## SirDice (Jul 25, 2016)

My first guess would be a forwarding rule that doesn't work. Are you sure you're forwarding to the correct IP? Also make sure there's not a firewall in between that's blocking the traffic.


----------



## nbsjbsd (Jul 25, 2016)

SirDice said:


> My first guess would be a forwarding rule that doesn't work. Are you sure you're forwarding to the correct IP? Also make sure there's not a firewall in between that's blocking the traffic.



Thanks for the response. I just double checked to make sure I am forwarding to the correct IP, all looks as it should. There is no firewall, only on the router and I'm able to switch back and forth from 192.168.2.56 (my new freebsd server that is having trouble) to my old Ubuntu server at 192.168.2.55. I change the port forwarding to .55 it works, switch it to .56 it fails. I should mention that this machine was running apache on Fedora previously with no issues. 

thanks again for the suggestions


----------



## SirDice (Jul 25, 2016)

Are you able to ping the router from the FreeBSD machine? Does the FreeBSD machine have a correct gateway?


----------



## nbsjbsd (Jul 25, 2016)

SirDice said:


> Are you able to ping the router from the FreeBSD machine? Does the FreeBSD machine have a correct gateway?


Thanks SirDice,

yep - all looks good there:

```
root@triglav:/var/log # cat /etc/rc.conf | grep router
defaultrouter="192.168.2.1"

root@triglav:/var/log # ping 192.168.2.1
PING 192.168.2.1 (192.168.2.1): 56 data bytes
64 bytes from 192.168.2.1: icmp_seq=0 ttl=64 time=0.224 ms
64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=0.207 ms
64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=0.207 ms
^C
--- 192.168.2.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.207/0.213/0.224/0.008 ms
```


----------



## SirDice (Jul 25, 2016)

Run a tcpdump(1) on the FreeBSD machine and verify you're actually seeing the connections come in. If you see in- and outgoing traffic check your router again. Make sure it's correctly NAT'ing the outgoing traffic.


----------



## nbsjbsd (Jul 25, 2016)

So I ran the tcpdump on the freebsd machine, triglav. The first few entries are from hits on my local network. Going outside my network, you can see the hits below in bold. So it appears traffic is making its way to the server yet nothing shows up in their browser

```
root@triglav:/var/log # tcpdump | grep http
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on fxp0, link-type EN10MB (Ethernet), capture size 65535 bytes
17:06:00.174501 IP fundy.41616 > triglav.http: Flags [F.], seq 2788243448, ack 2654853688, win 274, options [nop,nop,TS val 57170313 ecr 1562897583], length 0
17:06:00.174530 IP triglav.http > fundy.41616: Flags [.], ack 1, win 1040, options [nop,nop,TS val 1562919290 ecr 57170313], length 0
17:06:00.174559 IP fundy.41618 > triglav.http: Flags , seq 1203358705, win 29200, options [mss 1460,sackOK,TS val 57170313 ecr 0,nop,wscale 7], length 0
17:06:00.174574 IP triglav.http > fundy.41618: Flags [S.], seq 1497600931, ack 1203358706, win 65535, options [mss 1460,nop,wscale 6,sackOK,TS val 3639503003 ecr 57170313], length 0
17:06:00.174802 IP fundy.41618 > triglav.http: Flags [.], ack 1, win 229, options [nop,nop,TS val 57170313 ecr 3639503003], length 0
17:06:00.175014 IP fundy.41618 > triglav.http: Flags [P.], seq 1:627, ack 1, win 229, options [nop,nop,TS val 57170313 ecr 3639503003], length 626
17:06:00.280773 IP triglav.http > fundy.41618: Flags [.], ack 627, win 1040, options [nop,nop,TS val 3639503109 ecr 57170313], length 0
17:06:00.400869 IP triglav.http > fundy.41618: Flags [P.], seq 1:289, ack 627, win 1040, options [nop,nop,TS val 3639503229 ecr 57170313], length 288
17:06:00.401064 IP fundy.41618 > triglav.http: Flags [.], ack 289, win 237, options [nop,nop,TS val 57170370 ecr 3639503229], length 0
17:06:05.408046 IP triglav.http > fundy.41618: Flags [F.], seq 289, ack 627, win 1040, options [nop,nop,TS val 3639508236 ecr 57170370], length 0
17:06:05.447820 IP fundy.41618 > triglav.http: Flags [.], ack 290, win 237, options [nop,nop,TS val 57171632 ecr 3639508236], length 0
17:06:18.361238 IP fundy.41618 > triglav.http: Flags [F.], seq 627, ack 290, win 237, options [nop,nop,TS val 57174860 ecr 3639508236], length 0
17:06:18.361265 IP triglav.http > fundy.41618: Flags [.], ack 628, win 1040, options [nop,nop,TS val 3639521189 ecr 57174860], length 0
17:11:13.794996 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags , seq 856447625, win 65535, options [mss 1460,nop,wscale 5,nop,nop,TS val 732811845 ecr 0,sackOK,eol], length 0
17:11:13.795023 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [S.], seq 476934895, ack 856447626, win 65535, options [mss 1460,nop,wscale 6,sackOK,TS val 3121946085 ecr 732811845], length 0
17:11:13.801467 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [.], ack 1, win 4117, options [nop,nop,TS val 732811850 ecr 3121946085], length 0
17:11:13.955847 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [P.], seq 1:389, ack 1, win 4117, options [nop,nop,TS val 732812003 ecr 3121946085], length 388
17:11:14.002281 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [P.], seq 1:389, ack 1, win 4117, options [nop,nop,TS val 732812049 ecr 3121946085], length 388
17:11:14.002317 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [.], ack 389, win 1040, options [nop,nop,TS val 3121946292 ecr 732812003], length 0
17:11:14.130423 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [P.], seq 1:554, ack 389, win 1040, options [nop,nop,TS val 3121946420 ecr 732812003], length 553
17:11:14.134271 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [.], ack 554, win 4100, options [nop,nop,TS val 732812181 ecr 3121946420], length 0
17:11:16.347581 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [P.], seq 389:777, ack 554, win 4100, options [nop,nop,TS val 732814390 ecr 3121946420], length 388
17:11:16.440956 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [P.], seq 389:777, ack 554, win 4100, options [nop,nop,TS val 732814483 ecr 3121946420], length 388
17:11:16.441000 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [.], ack 777, win 1040, options [nop,nop,TS val 3121948731 ecr 732814390], length 0
17:11:16.519893 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [P.], seq 554:1106, ack 777, win 1040, options [nop,nop,TS val 3121948810 ecr 732814390], length 552
17:11:16.527058 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [.], ack 1106, win 4083, options [nop,nop,TS val 732814565 ecr 3121948810], length 0
17:11:21.533525 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [F.], seq 1106, ack 777, win 1040, options [nop,nop,TS val 3121953824 ecr 732814565], length 0
17:11:21.537328 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [.], ack 1107, win 4096, options [nop,nop,TS val 732819560 ecr 3121953824], length 0
17:11:22.445451 IP stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910 > triglav.http: Flags [F.], seq 777, ack 1107, win 4096, options [nop,nop,TS val 732820465 ecr 3121953824], length 0
17:11:22.445479 IP triglav.http > stjhnbsu1kw-142177028072.dhcp-dynamic.FibreOp.nb.bellaliant.net.58910: Flags [.], ack 778, win 1040, options [nop,nop,TS val 3121954736 ecr 732820465], length 0[/B]
```


----------



## nbsjbsd (Jul 25, 2016)

ok - I've got something screwy with my Apache conf that I'll have to figure out. When I go to my wiki site, it won't load but when I give it the complete url - mywikisiteurl/index.php/Main_Page then it loads but doesn't load the pics I have in my wiki. Internally it works flawlessly so I've got something buggered up. 

Anyway - thanks for the help, I'll report back when I figure out what the issue is.


----------



## nbsjbsd (Jul 25, 2016)

Update. Turns out it wasn't an Apache config after all. It was a setting in my mediawiki LocalSettings.php. There was this line:

```
## The protocol and server name to use in fully-qualified URLs
$wgServer = "[URL]http://192.168.2.56[/URL]";
```
Once I changed it to my actual wiki name

```
$wgServer = "[URL]http://mgbutler.sytes.net[/URL]";
```
It worked.

This variable is a new thing in the version of mediawiki I am using. I checked my old config on the old server and there is no such setting in the LocalSettings.php. More info here:
https://www.mediawiki.org/wiki/Manual:$wgServer

So all is good. Not a FreeBSD thing at all but thanks SirDice for the help - I appreciate it.


----------

