<p dir="ltr">I'm new to servers and proxies, <br>
But don't you think running both nginx and Apache on port 80 of same machine will cause one of those to fail to start.<br>
In my opinion backend should be on different IP:port combination.</p>
<p dir="ltr">Please correct me if I'm wrong.</p>
<div class="gmail_quote">On 05-Jul-2016 21:41, "NdridCold ." <project722@gmail.com> wrote:<br type='attribution'><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"> I was getting a host not found problem while trying to start nginx. <div><br /></div><div>nginx: [emerg] host not found in upstream "<a href="http://backendservers.com">backendservers.com</a>" in /etc/nginx/conf.d/default.conf:37<br /></div><div><br /></div><div>I am fairly certain that this is because there is no name resolution for "<a href="http://backendservers.com">backendservers.com</a>" in our DNS. So I changed up a few things to make it work. </div><div><br /></div><div>But I am confused on a few concepts here. First of all, should my server name in the "upstream" directive be the same name in the "server_name" directive in the "server" stanza? Here is what I have so far:</div><div><br /></div><div><br /></div><div><div>upstream <a href="http://myapplication.net">myapplication.net</a> {<!-- --></div><div> # Use ip hash for session persistance</div><div> ip_hash;</div><div> server <a href="http://1.net">1.net</a>;</div><div> server <a href="http://2.net">2.net</a>;</div><div> server 3..net;</div><div><br /></div><div> # The below only works on nginx plus</div><div> #sticky route $route_cookie $route_uri;</div><div>}</div><div>server {<!-- --></div><div><br /></div><div> listen 80;</div><div> server_name <a href="http://myapplication.net">myapplication.net</a>;</div><div> keepalive_timeout 70;</div><div><br /></div><div> #charset koi8-r;</div><div> #access_log /var/log/nginx/log/host.access.log main;</div><div><br /></div><div> location / {<!-- --></div><div> root /usr/share/nginx/html;</div><div> index index.html index.htm;</div><div> }</div><div><br /></div><div> #error_page 404 /404.html;</div><div><br /></div><div> # redirect server error pages to the static page /50x.html</div><div> #</div><div> error_page 500 502 503 504 /50x.html;</div><div> location = /50x.html {<!-- --></div><div> root /usr/share/nginx/html;</div><div> }</div><div><br /></div><div> # proxy the PHP scripts to Apache listening on <a href="http://127.0.0.1:80">127.0.0.1:80</a></div><div> #</div><div> location ~ \.php$ {<!-- --></div><div> proxy_pass <a href="http://myapplication.net">http://myapplication.net</a>;</div><div> proxy_http_version 1.1;</div><div> proxy_set_header Connection "";</div><div> }</div><div><br /></div><div> # pass the PHP scripts to FastCGI server listening on <a href="http://127.0.0.1:9000">127.0.0.1:9000</a></div><div> #</div><div> #location ~ \.php$ {<!-- --></div><div> # root html;</div><div> # fastcgi_pass <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;</div><div> # fastcgi_index index.php;</div><div> # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;</div></div><div><br /></div><div> # include fastcgi_params; </div><div> #} </div><div><br /></div><div> # deny access to .htaccess files, if Apache's document root</div><div> # concurs with nginx's one </div><div> # </div><div> #location ~ /\.ht {<!-- --></div><div> # deny all;</div><div> #} </div><div>}</div><div><br /></div><div>server {<!-- --></div><div><br /></div><div> listen 443 ssl;</div><div> server_name <a href="http://myapplication.net">myapplication.net</a>;</div><div> keepalive_timeout 70;</div><div><br /></div><div> #charset koi8-r;</div><div> #access_log /var/log/nginx/log/host.access.log main;</div><div><br /></div><div> location / {<!-- --></div><div> root /usr/share/nginx/html;</div><div> index index.html index.htm;</div><div> }</div><div><br /></div><div> #error_page 404 /404.html;</div><div><br /></div><div> # redirect server error pages to the static page /50x.html</div><div> #</div><div> error_page 500 502 503 504 /50x.html;</div><div> location = /50x.html {<!-- --></div><div> root /usr/share/nginx/html;</div><div> }</div><div><br /></div><div> # proxy the PHP scripts to Apache listening on <a href="http://127.0.0.1:80">127.0.0.1:80</a></div><div> #</div><div> location ~ \.php$ {<!-- --></div><div> proxy_pass <a href="https://myapplication.net">https://myapplication.net</a>;</div><div> proxy_http_version 1.1;</div><div> proxy_set_header Connection "";</div><div> }</div><div><br /></div><div> # pass the PHP scripts to FastCGI server listening on <a href="http://127.0.0.1:9000">127.0.0.1:9000</a></div><div> #</div><div> #location ~ \.php$ {<!-- --></div><div> # root html;</div><div> # fastcgi_pass <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;</div><div> # fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;</div><div> # include fastcgi_params; </div><div> #} </div><div><br /></div><div> # deny access to .htaccess files, if Apache's document root</div><div> # concurs with nginx's one </div><div> # </div><div> #location ~ /\.ht {<!-- --></div><div> # deny all;</div><div> #} </div><div><br /></div><div>So here is what I need to happen. I need nginx to asnwer requests for <a href="http://myapplication.net">myapplication.net</a> and send them to the servers "server1,net, <a href="http://server2.net">server2.net</a>, and <a href="http://server3.net">server3.net</a>". Am I accomplishing this with this config? And to recap, should my server name in the "upstream" directive be the same name in the "server_name" directive in the "server" stanza?</div><div> </div></div>
</blockquote></div>