mod_unique_id: unable to find IPv4 address of FQDN despite setting etc/hosts and Apache ServerName

27

Solution 1

The problem was SELinux

#less /var/log/audit/audit.log

type=AVC msg=audit(1311546944.235:1040): avc:  denied  { read } for  pid=1396 comm="httpd" 
name="hosts" dev=dm-0 ino=262931 
scontext=user_u:system_r:httpd_t:s0 
tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file

In my case the following solved it:

# ls -lZ /etc/hosts
-rw-r--r--  root root system_u:object_r:initrc_tmp_t   /etc/hosts
# setenforce 0
# restorecon -R -F -v /etc/hosts
# setenforce 1
# ls -lZ /etc/hosts
-rw-r--r--  root root system_u:object_r:etc_t          /etc/hosts

Solution 2

I'd be looking for typos and other "stupidly simple" mistakes we all make from time to time (I use my wife as a proof-reader), but if that doesn't work I'd just fire up strace to see what mod_security is trying to do. It might not be reading /etc/hosts -- perhaps it's taking a failure to resolve the name via DNS as some sort of hard failure instead, or something else.

At any rate, I'd be putting the machine's name in DNS anyway. It just saves so many hassles.

Share:
27

Related videos on Youtube

user1010101
Author by

user1010101

Updated on September 18, 2022

Comments

  • user1010101
    user1010101 over 1 year

    I would like to work on a ruby on rails project with a group of 4 people. If we install rails 4.2.0 how can we ensure that we all share the same environment? Is the only option to have install VM? or is there some other way? I mean what if one user is using mac another is on windows and another is on Linux? How can we ensure all are having same environment so there is no configuration issues etc? What is the easiest solution?

    • Marc Baumbach
      Marc Baumbach about 9 years
      You'll have to be more specific, I think. Do you just mean the same database, or do you have external dependencies? Usually making sure you use a SCM tool and Bundler correctly, you should all have the same environment. If your concern is more OS, then a VM like Vagrant or Docker may be your best choice.
  • KCD
    KCD almost 13 years
    Yes I've been struggling to rule out problems existing between the keyboard and the chair. Asking our hosting provider to add the computer name to the DNS would help but it would be nice to know why apache doesn't seem to process the hosts file
  • KCD
    KCD almost 13 years
    Awarded this as the solution because strace identified the true problem and a DNS entry would've solved it either way
  • womble
    womble almost 13 years
    It'd be worth putting the reason you found in as an answer, for future searchers who come across your question and would like to know exactly what the answer was. I'm curious too, now.
  • KCD
    KCD almost 13 years
    I'm one step ahead of you, see the third section added to the question. SELinux was the problem, I'll edit it to make it clearer. Thanks again for your help!
  • womble
    womble almost 13 years
    I'm saying make it an answer, not part of your question -- self-answering is explicitly encouraged, as not everyone who finds the question will read the whole question, they'll skim just enough to see that it fits their problem and then skip straight to the answers.
  • KCD
    KCD almost 13 years
    Fair enough. Only reason I didn't do that is so I could credit you with the answer :)
  • womble
    womble almost 13 years
    I'm wonderfully selfless... although you don't have to take away my precioussssssss accepted tick. <grin>
  • KCD
    KCD almost 13 years
    Ha indeed, chances are you'll answer my next question anyway (note to self - learn about StackExchange 'Chat')
  • user1010101
    user1010101 about 9 years
    Is there some free solution available ?
  • Amit Joki
    Amit Joki about 9 years
    @Learner afaik, I don't know of any free solution to this.
  • Antarr Byrd
    Antarr Byrd about 9 years
    @Learner I haven't used it but you may want to look at Runnable
  • user1010101
    user1010101 about 9 years
    One of my group member is insisting we all download VM so we have identical vdi image or else it will be an issue. I am new to rails so i wanted to make sure if this is the case.