Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a nice little Server with Ubuntu 12.04 LTS with Apache controlled by plesk. Now I've installed nginx for my Gitlab subdomain.

But now nginx wants to control all. How can I configure the nginx server to provide only one subdomain: git.example.com

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can't run them both on the same port. By default both will want to conquer 0.0.0.0:80 and that's not on. Two simple choices:

  • Add an IP, bind nginx on its port 80, point DNS at that IP.
  • Set nginx up on another port (eg 8080) and use Apache's ProxyPass directive to push one virtualhost back to nginx:

    <VirtualHost *:80>
        ServerName git.example.com
        DocumentRoot /path/to/myapp/public
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/
    </VirtualHost>
    

    This is actually quite common - just in reverse. Most people put nginx on the raw port 80 and let it handle raw file IO, and proxy back to Apache if they need something like mod_php. You could do that but it's very likely more work.

There are —as always— a hundred thousand million different ways of doing these sorts of things. These are the two main ones.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.