title: Apache & Nginx on same Server leads to conflict with gitlab
body: <p>I tried to install Gitlab on my webserver. I configured everything appropriately. This is a scheme of what I am trying to achieve:</p>
  
  <ul>
  <li>example.com:80 (default host)  
  
  <ul>
  <li>vhost1.example.com:80 (a virtual host)</li>
  </ul></li>
  <li>example.com:8080 (gitlab)</li>
  </ul>
  
  <p>So what happens is this: I can open example.com and vhost1.example.com normally. If gitlab-ctl is stopped, I get a "Website not available"-error if I try to open example.com:8080 (as expected). When I start gitlab and try to open example.com:8080 again, it shows me the gitlab-error "502 Error GitLab is taking too much time to respond", but only the first time I load this page, as soon as I refresh or try it again in a new tab, it redirects my request always to example.com, although I request the page with ":8080" at the end.</p>
  
  <p>I have access to gitlab with <a href="http://x.x.x.x:8080" rel="nofollow">http://x.x.x.x:8080</a>. This works but I'm forced to configure <a href="http://example.com:8080" rel="nofollow">http://example.com:8080</a></p>
  
  <p>System:</p>
  
  <ul>
  <li>Debian Wheezy</li>
  <li>Apache/2.2.22</li>
  <li>gitlab-ce_8.4.1-ce (includes nginx)</li>
  </ul>
  
  <p>Here are my configuration files:</p>
  
  <p><strong>/etc/apache2/sites-available/example.com</strong></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin mail@example.com
      ServerName example.com
      ServerAlias www.example.com
      DocumentRoot /var/www/example.com
      ErrorLog ${APACHE_LOG_DIR}/error_example.com.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      &lt;Directory /var/www/example.com&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Order allow,deny
              Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>/etc/apache2/sites-available/vhost1.example.com</strong></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin mail@example.com
      ServerName vhost1.example.com
      ServerAlias www.vhost1.example.com
      DocumentRoot /var/www/vhost1.example.com
      ErrorLog ${APACHE_LOG_DIR}/error_vhost1.example.com.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
              &lt;Directory /var/www/vhost1.example.com&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Order allow,deny
              Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>/etc/apache2/ports.conf (only changes)</strong></p>
  
  <pre><code>NameVirtualHost *:80
  Listen x.x.x.x:80
  
  &lt;IfModule mod_ssl.c&gt;
      Listen x.x.x.x:443
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_gnutls.c&gt;
      Listen x.x.x.x:443
  &lt;/IfModule&gt;
  </code></pre>
  
  <p><strong>/etc/gitlab/gitlab.rb (only changes)</strong></p>
  
  <pre><code>external_url 'http://example.com:8080'
  unicorn['port'] = 8081
  nginx['listen_addresses'] = ["x.x.x.x"]
  nginx['listen_port'] = 8080
  </code></pre>
  
  <p><strong>netstat -napl | grep :80</strong></p>
  
  <pre><code>tcp        0      0 x.x.x.x:8080     0.0.0.0:*               LISTEN      19037/nginx     
  tcp        0      0 x.x.x.x:80       0.0.0.0:*               LISTEN      18280/apache2   
  tcp        0      0 127.0.0.1:8081   0.0.0.0:*               LISTEN      19110/config.ru 
  </code></pre>
  
  <p>I would really appreciate every hint. If you need further information just ask.</p>