# Error while connecting to apache from nginx running on same machine

**URL:** <https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408>\
**Category:** NGINX\
**Created:** [June 8, 2012, 9:56am UTC](https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408 "2012-06-08T09:56:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 8, 2012, 9:56am UTC](https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408/1 "2012-06-08T09:56:20Z")

</div>

Hi,

```
I have an LB setup with nginx for an ssl enabled website. It will be

```

listening at 443 port. For some requests, i need to proxy them to apache  
running at 7443 port in the same machine. but when i send the request,  
it is trying to forward it to apache and is getting 500 error. I checked  
the logs in apache, where there is nothing logged in ssl-error\_log  
(which logs all the errors happening while transferring https requests)  
but the error\_log (which logs all the errors happening while  
transferring http requests) was showing the message like [error]  
Hello

But if I pass it to apache running in 7443 in some other machine, it is  
working fine.

So, I think there is some problem while handshaking between nginx and  
apache running on different ports in the same machine. Can some one  
please assist me how to resolve this…Thanks in advance…

Posted at Nginx Forum:

> **[Error while connecting to apache from nginx running on same machine](https://forum.nginx.org/read.php?2,227341,227341#msg-227341)**
>
> Hi, I have an LB setup with nginx for an ssl enabled website. It will be listening at 443 port. For some requests, i need to proxy them to apache running at 7443 port in the same machine. but when i send the request, it is trying to forward it to...

---

<div class="post-metadata">

**Author:** ![lima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e5b9ba/32.png) [@lima](https://www.ruby-forum.com/u/lima)\
**Post date:** [June 8, 2012, 10:32pm UTC](https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408/2 "2012-06-08T22:32:01Z")

</div>

Show us the relative config parts, we’re just guessing without it.

Posted at Nginx Forum:

> **[Re: Error while connecting to apache from nginx running on same machine](https://forum.nginx.org/read.php?2,227341,227371#msg-227371)**
>
> Hi, I have an LB setup with nginx for an ssl enabled website. It will be listening at 443 port. For some requests, i need to proxy them to apache running at 7443 port in the same machine. but when i send the request, it is trying to forward it to...

---

<div class="post-metadata">

**Author:** ![lima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e5b9ba/32.png) [@lima](https://www.ruby-forum.com/u/lima)\
**Post date:** [June 11, 2012, 10:26am UTC](https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408/3 "2012-06-11T10:26:18Z")

</div>

Hi,  
This is our nginx configuration setup.

* * *

http {  
include mime.types;

```
gzip on;
gzip_http_version 1.1;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml text/css

```

application/x-javascript text/xml application/javascript  
text/javascript;  
gzip\_disable “MSIE [1-6].”;

```
autoindex off;
ssi off;
server_tokens off;

log_format main '$remote_addr [$time_local] - "$request" - '
                  '$status - $body_bytes_sent - "$http_referer"';

log_format lb_log '$remote_addr [$time_local] - "$request" - $status

```

- ’  
'worker\_addr $upstream\_addr - ’  
'worker\_status $upstream\_status - ’  
'worker\_response\_time $upstream\_response\_time - ’  
'total\_processing\_time $request\_time - ’  
‘content\_type $upstream\_http\_content\_type’;

/root/Apache\_New\_SSL\_Keys/lendingstream.co.uk.crt;  
ssl\_certificate\_key  
/root/Apache\_New\_SSL\_Keys/lendingstream.key.nopass;  
ssl\_session\_timeout 3m;  
ssl\_protocols SSLv3;  
ssl\_ciphers HIGH:!aNULL:!MD5;  
ssl\_prefer\_server\_ciphers on;

```
    proxy_redirect / /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_read_timeout 360s;

    location ~ ^/documents/ {
       proxy_pass https://docproxy;
       access_log logs/doc_access.log doc_log;
    }
    location / {
       proxy_pass https://loadbalancer;
       access_log logs/lb_access.log lb_log;
    }

    error_page 403 /403.html;
    error_page 404 /404.html;
    error_page 500 502 503 504 /500.html;

    location ~ ^/(403.html|404.html|500.html)$ {
        root html;
    }
}

```

}

* * *

Here, we will forward all the requests except documents to LB, which in  
turn send to either server1 or server2. The document related requests  
will be proxy forwarded to apache running in the same machine at 7443  
port. But, here comes the problem that when it is sending any request to  
apache it is giving 500 error. In apache logs, it’s been logged as  
[error] Hello. The apache configurations are:

## httpd.conf is,

ServerRoot “/usr/local/apache2”  
PidFile logs/httpd.pid  
Listen 80  
ServerTokens ProductOnly  
ServerSignature Off

###### Loaded all modules which are required

LoadModule \*\*\*\*\*.so

###### Loaded all modules which are required

\<IfModule !mpm\_netware\_module\>  
\<IfModule !mpm\_winnt\_module\>  
User USER  
Group GROUP

DocumentRoot “/usr/local/apache2/htdocs”

 Options -Indexes +FollowSymLinks AllowOverride None Order deny,allow Deny from all

\<Directory “/usr/local/apache2/htdocs”\>  
Options -Indexes +FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

ErrorLog “logs/error\_log”  
LogLevel notice

 SSLRandomSeed startup builtin SSLRandomSeed connect builtin

\<VirtualHost \*:80\>  
Alias /documents /home/documents  
\<Directory /home/documents\>  
Order deny,allow  
Allow from all

```
WSGIScriptAlias / apache/django.wsgi
<Directory "apache">

```

Order allow,deny  
Allow from all

* * *

## and the httpd-ssl.conf is,

LoadModule ssl\_module modules/mod\_ssl.so  
LoadModule wsgi\_module modules/mod\_wsgi.so

Listen 7443  
AddType application/x-x509-ca-cert .crt  
AddType application/x-pkcs7-crl .crl

SSLPassPhraseDialog builtin

SSLSessionCache  
“shmcb:/usr/local/apache2/logs/ssl\_scache(512000)”  
SSLSessionCacheTimeout 15  
SSLMutex “file:/usr/local/apache2/logs/ssl\_mutex”

---

<div class="post-metadata">

**Author:** ![lima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e5b9ba/32.png) [@lima](https://www.ruby-forum.com/u/lima)\
**Post date:** [June 11, 2012, 12:59pm UTC](https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408/4 "2012-06-11T12:59:59Z")

</div>

– proxy\_pass [https://docproxy](https://docproxy);  
Points to 443,

Yet the upstream wants 7443…  
– upstream docproxy {  
– server 127.0.0.1:7443;  
– }

Posted at Nginx Forum:

> **[Re: Error while connecting to apache from nginx running on same machine](https://forum.nginx.org/read.php?2,227341,227424#msg-227424)**
>
> Hi, I have an LB setup with nginx for an ssl enabled website. It will be listening at 443 port. For some requests, i need to proxy them to apache running at 7443 port in the same machine. but when i send the request, it is trying to forward it to...

---

<div class="post-metadata">

**Author:** ![lima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e5b9ba/32.png) [@lima](https://www.ruby-forum.com/u/lima)\
**Post date:** [June 11, 2012, 4:36pm UTC](https://www.ruby-forum.com/t/error-while-connecting-to-apache-from-nginx-running-on-same-machine/220408/5 "2012-06-11T16:36:16Z")

</div>

Hey,I found the problem…anyway thank u very much…

Posted at Nginx Forum:

> **[Re: Error while connecting to apache from nginx running on same machine](https://forum.nginx.org/read.php?2,227341,227437#msg-227437)**
>
> Hi, I have an LB setup with nginx for an ssl enabled website. It will be listening at 443 port. For some requests, i need to proxy them to apache running at 7443 port in the same machine. but when i send the request, it is trying to forward it to...
