# Does nginx forward requests to backend servers using http or https?

**URL:** <https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900>\
**Category:** NGINX\
**Created:** [July 5, 2016, 4:27pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900 "2016-07-05T16:27:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 5, 2016, 4:27pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900/1 "2016-07-05T16:27:20Z")

</div>

I am using the free version of nginx on RHEL 6.7. The version is :

nginx-1.10.1-1.el6.ngx.x86\_64

When using nginx as a load balancer I would like to know if nginx  
forwards requests to backend servers using http or https??

---

<div class="post-metadata">

**Author:** ![Brian\_Pugh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@Brian\_Pugh](https://www.ruby-forum.com/u/Brian_Pugh)\
**Post date:** [July 5, 2016, 4:34pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900/2 "2016-07-05T16:34:20Z")

</div>

You define what you want it sent to the backend as. So if you use  
[http://backendserver](http://backendserver) it’s http, if [https://backendserver:443](https://backendserver:443) - https.

---

<div class="post-metadata">

**Author:** ![Brian\_Pugh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@Brian\_Pugh](https://www.ruby-forum.com/u/Brian_Pugh)\
**Post date:** [July 5, 2016, 4:42pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900/3 "2016-07-05T16:42:31Z")

</div>

Are you referring to the proxy pass declaration? If so I get an error  
when I uncomment that line out saying “nginx: [emerg] “proxy\_pass”  
directive is not allowed here in /etc/nginx/conf.d/default.conf:40?”

* * *

From: nginx [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) on behalf of Drew Turner  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, July 5, 2016 9:33 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: does nginx forward requests to backend servers using http  
or https?

You define what you want it sent to the backend as. So if you use  
[http://backendserver](http://backendserver) it’s http, if [https://backendserver:443](https://backendserver:443) - https.

On Tue, Jul 5, 2016 at 9:26 AM, Brian Pugh  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I am using the free version of nginx on RHEL 6.7. The version is :

nginx-1.10.1-1.el6.ngx.x86\_64

When using nginx as a load balancer I would like to know if nginx  
forwards requests to backend servers using http or https??

---

<div class="post-metadata">

**Author:** ![Brian\_Pugh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@Brian\_Pugh](https://www.ruby-forum.com/u/Brian_Pugh)\
**Post date:** [July 5, 2016, 4:47pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900/4 "2016-07-05T16:47:47Z")

</div>

Yes that is in proxy\_pass. Are you sure proxy\_pass is defined in the  
server stanza and that it’s inside an include stanza?

Posting the code would be helpful if you can redact the sensitive  
information.

---

<div class="post-metadata">

**Author:** ![Brian\_Pugh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@Brian\_Pugh](https://www.ruby-forum.com/u/Brian_Pugh)\
**Post date:** [July 5, 2016, 5:05pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900/5 "2016-07-05T17:05:54Z")

</div>

Yes, However I did not have the entire stanza un-commented out. I have  
done  
that, but now I am encountered with a different error message. Now I  
get:

nginx: [emerg] host not found in upstream “[resolveservergroup.com](http://resolveservergroup.com)” in  
/etc/nginx/conf.d/default.conf:40

Here is my default.conf file:

upstream [backendservergroup.com](http://backendservergroup.com) {  
# Use ip hash for session persistance  
ip\_hash;  
# backend server 1  
server 192.168.155.120;  
# backend server 2  
server 192.168.155.126;  
# backend server 3  
server 192.168.155.127;

```
    # The below only works on nginx plus
    #sticky route $route_cookie $route_uri;

```

}  
server {

```
listen 80;
server_name nginxserver.com;
keepalive_timeout 70;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
    proxy_pass http://backendservergroup.com;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}

```

}

server {

```
listen 443 ssl;
server_name nginxserver.com;
keepalive_timeout 70;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
   proxy_pass https://backendservergroup.com:443;
   proxy_http_version 1.1;
   proxy_set_header Connection "";

```

}

```
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}

```

---

<div class="post-metadata">

**Author:** ![Brian\_Pugh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@Brian\_Pugh](https://www.ruby-forum.com/u/Brian_Pugh)\
**Post date:** [July 5, 2016, 9:55pm UTC](https://www.ruby-forum.com/t/does-nginx-forward-requests-to-backend-servers-using-http-or-https/244900/6 "2016-07-05T21:55:04Z")

</div>

can you move the backend server declaration from your .conf file to the  
nginx.conf file inside the http stanza?
