2

I am creating a set up of Mailman, Apache2.4 and Postfix. My problem is as follows. When I access the mailing list with the domain name, I get the correct result in my browser. Here the picture

Normal mailman front page

However if I try to access directly using my server's IP address, I get a different page, where the mailing lists are missing. This is how it looks like:

enter image description here The desired result is getting exactly the same page.

The apache2 configuration is as follows:

<Directory /usr/lib/cgi-bin/mailman/>
    AllowOverride None
    Options +ExecCGI
    AddHandler cgi-script .cgi
    # (Old apache2.2 style configuration:)
    # Order allow,deny
    # Allow from all
    # New apache 2.4 configuration:
    Require all granted
</Directory>
<Directory /var/lib/mailman/archives/public/>
    Options FollowSymlinks
    AllowOverride None
    # (Old configuration:)
    # Order allow,deny
    # Allow from all
    # New apache 2.4 configuration:
    Require all granted
</Directory>
<Directory /usr/share/images/mailman/>
    AllowOverride None
    # (Old configuration:)
    # Order allow,deny
    # Allow from all 
    # New apache 2.4 configuration:
    Require all granted
</Directory>


<VirtualHost *:80>
ServerName lists.example.org
DocumentRoot /var/www/lists
ErrorLog /var/log/apache2/lists-error.log
CustomLog /var/log/apache2/lists-access.log combined

<Directory /var/lib/mailman/archives/>
    Options FollowSymLinks
    AllowOverride None
</Directory>

Alias /archives/ /var/lib/mailman/archives/public/
Alias /images/mailman/ /usr/share/images/mailman/
ScriptAlias /admin /usr/lib/cgi-bin/mailman/admin
ScriptAlias /admindb /usr/lib/cgi-bin/mailman/admindb
ScriptAlias /confirm /usr/lib/cgi-bin/mailman/confirm
ScriptAlias /create /usr/lib/cgi-bin/mailman/create
ScriptAlias /edithtml /usr/lib/cgi-bin/mailman/edithtml
ScriptAlias /listinfo /usr/lib/cgi-bin/mailman/listinfo
ScriptAlias /options /usr/lib/cgi-bin/mailman/options
ScriptAlias /private /usr/lib/cgi-bin/mailman/private
ScriptAlias /rmlist /usr/lib/cgi-bin/mailman/rmlist
ScriptAlias /roster /usr/lib/cgi-bin/mailman/roster
ScriptAlias /subscribe /usr/lib/cgi-bin/mailman/subscribe
ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/
ScriptAlias / /usr/lib/cgi-bin/mailman/listinfo/
</VirtualHost>

EDIT: I include here my mm_cfg.py file (Mailman configuration):

from Defaults import *

MAILMAN_SITE_LIST = 'mailman'

DEFAULT_URL_PATTERN = 'http://%s/'
# PRIVATE_ARCHIVE_URL = '/cgi-bin/mailman/private'
PUBLIC_ARCHIVE_URL = 'http://%(hostname)s/archives/%(listname)s'
IMAGE_LOGOS         = '/mailman-icons/'

# Default domain for email addresses of newly created MLs
DEFAULT_EMAIL_HOST = 'lists.example.org'

# Default host for web interface of newly created MLs
DEFAULT_URL_HOST   = 'lists.example.org'

VIRTUAL_HOSTS.clear()
add_virtualhost(DEFAULT_URL_HOST,DEFAULT_EMAIL_HOST)

DEFAULT_SERVER_LANGUAGE = 'en'
USE_ENVELOPE_SENDER    = 0              # Still used?
DEFAULT_SEND_REMINDERS = 0
MTA='Postfix'

Besides that, I disable the default site by running:

sudo a2dissite 000-default

I noticed that if I don't disable 000-default, accessing the webpage using the IP address gives me the default Apache page that says everything is ok.

I wonder if there is some elegant solution to the direct IP access problem, making it show the same page as the one I see when I use the domain name.

EDIT: I tried changing to (Inside mm_cfg.py):

VIRTUAL_HOSTS.clear()
add_virtualhost("104.131.98.138","lists.example.org")

As suggested. I get the correct page when I use the url lists.example.org, however when I use the IP address I get this: Entering mailman directly using IP

Note however that this time the email address is correct.

I get the same results also when both lines are present:

VIRTUAL_HOSTS.clear()
add_virtualhost(DEFAULT_URL_HOST,DEFAULT_EMAIL_HOST)
add_virtualhost("104.131.98.138","lists.example.org")
real
  • 123
  • 1
  • 5

1 Answers1

1

First, pardon me for misdirection here because I misunderstanding your intention in the past. Now, as far as I understand, your intention is aliasing 104.131.98.138 to lists.freedomlayer.org - so when you browse through either 104.131.98.138 and lists.freedomlayer.org you get same result - YES?

Unfortunately, it isn't possible with mailman. Mailman expect single unique URL for every list. More info, click this FAQ from mailman documentation

Anyway you can set redirection in Apache. So whenever user doesn't use http://lists.freedomlayer.org to go to mailman web page (i.e. using http://104.131.98.138) it will redirected to http://lists.freedomlayer.org.

Here the apache config to get your redirection works

RewriteEngine On
RewriteCond %{HTTP_HOST} !^lists\.freedomlayer\.org [NC]
RewriteRule ^(.*)$ http://lists.freedomlayer.org/$1 [R=301,L]
masegaloeh
  • 18,236
  • 10
  • 57
  • 106
  • 1
    Thanks for the answer. I tried adding the line as suggested. I still have two different pages though. This time in the access through IP address case I get the mail address as mailman@lists.example.org (Earlier It was mailman@ip-address), so it did make some difference. – real Nov 23 '14 at 15:41
  • @real two suggestions: (1) could you replace `add_virtualhost(DEFAULT_URL_HOST,DEFAULT_EMAIL_HOST)` with `add_virtualhost('192.168.99.99', 'lists.example.com')` in mm_cfg.py and restart mailman (2) If it still fails please post the screenshot also :) – masegaloeh Nov 24 '14 at 01:53
  • 1
    Thanks again for your message. I tried replacing the lines, however I get similar results. If it helps somehow, the full configuration is here: https://github.com/realcr/mailman_docker – real Nov 25 '14 at 10:35
  • Thanks, for the docker. However when I tried to play it in my bare new VPS, it doesn't works because permission issue. – masegaloeh Nov 26 '14 at 04:19
  • As docker expects to run as root, you should add sudo to all of my scripts. Did the permission issue showed up from the host, or inside the container? – real Nov 26 '14 at 14:59
  • Inside the container. I had to run `check_perms -f` before `service mailman restart` :). Anyway this is OOT (we can continue in github though :)). See my updated answer – masegaloeh Nov 26 '14 at 15:05
  • I understand the idea you propose here. I think this what I'm going to do eventually. Just one more comment about it: I think using mod alias in this case could be a bit cleaner. (http://httpd.apache.org/docs/current/mod/mod_alias.html). Thank you for your help. Be sure to send me a message if the docker thing still doesn't work for you. – real Nov 26 '14 at 15:09
  • You can try to use mod_alias in this case (I don't know that will works or not). Please edit my answer in case you have alternative way to getting redirection works. – masegaloeh Nov 26 '14 at 15:13