skip to Main Content

As a newbie set up mediawiki in apache httpd on my linux pc. In the corresponding .conf file "require all granted’" is set. The pc was assigned static IP 192.168.0.2 by the router. The port 80 of the pc is opened for any device. I visited http://192.168.0.2/mediawiki/index.php from the host. It worked as expected. Now I tried to visit the same address from my android phone connected to the same network and I was presented with the message "127.0.0.1 refused to connect" by chrome. I noticed that the part http://192.168.0.2 had been replaced by https://127.0.0.1 in the address bar. The same thing also occurred on Firefox on my phone. I can still visit http://192.168.0.2 from my phone and it works just fine. So what is happening here and how to solve this problem?

EDIT: The problem is solved. Mediawiki has this LocalSettings.php file which gets automatically created during installation. It contains a field "$wgServer" which is the "The protocol and server name to use in fully-qualified URLs" as shown in the documentation. This value was automatically set to "http://127.0.0.1" during the installation. Thereby whenever I was trying to connect to mediawiki from my phone I was actually getting redirected to that same phone. I changed the value to "http://192.168.0.2" and now everything is working fine!

2

Answers


  1. Looks like something happened at the connection from your mobile phone to the pc hosting the web server.
    Your configuration looks fine even tho you provided almost no details at all: according to your description, I suspect the problem is on your phone or on your router because the domain and url switched from 192.168.0.2 to 127.0.0.1 and the protocol switched from http to https.

    You should try the same test from another pc connected to the same network.
    You can have a better understanding of what’s happening, testing the connection from command line using curl:

    $ curl -v http://192.168.0.2/mediawiki/index.php

    The output will give you some details of what’s going on if the redirect was requested by the webserver or not.

    Login or Signup to reply.
  2. My guess is that your apache is configured to listen to 127.0.0.1 or localhost (it’s the default). Open httpd.conf or your virtual host configuration file and look for Listen. Here’s some snippets from the official documentation:

    The Listen directive tells the server to accept incoming requests only on the specified port(s) or address-and-port combinations. If only a port number is specified in the Listen directive, the server listens to the given port on all interfaces. If an IP address is given as well as a port, the server will listen on the given port and interface. Multiple Listen directives may be used to specify a number of addresses and ports to listen on. The server will respond to requests from any of the listed addresses and ports.

    For example, to make the server accept connections on both port 80 and port 8000, on all interfaces, use:

    Listen 80
    Listen 8000
    

    To make the server accept connections on port 80 for one interface, and port 8000 on another, use

    Listen 192.0.2.1:80
    Listen 192.0.2.5:8000
    

    More information at

    https://httpd.apache.org/docs/2.4/bind.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search