Skip to main content

502 bad gateway nginx and apache servers

itemprop="text">

Hello there can you please help me im
trying to setup apache and nginx server on my ubuntu 16.04 server, but when i try to
visit localhost/info.php fo example im
getting




502 Bad
Gateway nginx/1.9.15
(Ubuntu)





error
502 bad gateway and this is from the error log
file:




2017/01/24
10:50:55 [error] 14774#14774: *29 connect() failed (111: Connection refused) while
connecting to upstream, client:
127.0.0.1, server: example.com, request: "GET
/info.php HTTP/1.1", upstream: " rel="nofollow noreferrer">http://127.0.0.1:8080/info.php", host:
"localhost"




my
/etc/apache2/ports.conf
is:




Listen
8000


Listen
443


mod_gnutls.c>
Listen
443




my
/etc/nginx/sites-available/default file
is:



server {
listen 80
default_server;
listen [::]:80 default_server;

root
/var/www/html;


# Add index.php to the list if you are
using PHP
index index.php index.html index.htm
index.nginx-debian.html;

server_name
127.0.0.1;

location / {
# First attempt to serve
request as file, then
# as directory, then fall back to displaying a
404.
try_files $uri $uri/ =404;
proxy_pass
http://127.0.0.1:8000;

include /etc/nginx/proxy_params;

}

location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$
{
expires 30d;
}

}


location @proxy {

proxy_pass http://127.0.0.1:8000;

include /etc/nginx/proxy_params;
}
location ~* \.php$ {

proxy_pass http://127.0.0.1:8000;
include /etc/nginx/proxy_params;

}
}



my
/etc/nginx/nginx.conf file:



user
www-data;
worker_processes auto;
pid
/run/nginx.pid;

events {
worker_connections
768;
# multi_accept on;
}


http
{

##
# Basic Settings

##

sendfile on;
tcp_nopush on;
tcp_nodelay
on;

keepalive_timeout 65;
types_hash_max_size
2048;
# server_tokens off;

#
server_names_hash_bucket_size 64;
# server_name_in_redirect
off;

include /etc/nginx/mime.types;
default_type
application/octet-stream;


##
# SSL
Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #
Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers
on;

##
# Logging Settings

##


access_log /var/log/nginx/access.log;

error_log /var/log/nginx/error.log;

##
# Gzip
Settings
##

gzip on;
gzip_disable
"msie6";


# gzip_vary on;
# gzip_proxied
any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
#
gzip_http_version 1.1;
# gzip_types text/plain text/css application/json
application/javascript text/xml application/xml application/xml+rss
text/javascript;

##
# Virtual Host
Configs

##

include
/etc/nginx/conf.d/*.conf;
include
/etc/nginx/sites-enabled/*;
}


rights
and ownerships of /var/www/html
folder:



➜ html sudo ls -lah
/var/www/html

общо 40K
drwx--s--x 6 dimitar www-data
4,0K яну 24 10:44 .
drwxr-sr-x 3 dimitar www-data 4,0K дек 28 12:26
..
-rw-r-Sr-- 1 dimitar www-data 12K яну 24 00:52
index.html
-rw-r--r-- 1 dimitar www-data 18 яну 24 10:44
info.php
drwxrwsr-x 6 dimitar www-data 4,0K яну 10 14:02
Laracast
drwxrwsr-x 2 dimitar www-data 4,0K яну 23 20:17
phpmyadmin
drwxrwxrwx 5 dimitar www-data 4,0K дек 16 11:28
softuni
drwxrwsr-x 12 dimitar www-data 4,0K яну 3 20:04
users



the
output of sudo netstat
-lntp:



Active Internet connections
(only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 0.0.0.0:7845 0.0.0.0:* LISTEN 5054/skype

tcp 0 0 127.0.0.1:30666 0.0.0.0:* LISTEN 31454/Viber
tcp 0 0
127.0.0.1:3306 0.0.0.0:* LISTEN 2521/mysqld
tcp 0 0 0.0.0.0:139 0.0.0.0:*
LISTEN 2523/smbd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14328/nginx -g
daem

tcp 0 0 127.0.0.1:4371 0.0.0.0:* LISTEN 28075/spotify

tcp 0 0 127.0.0.1:5940 0.0.0.0:* LISTEN 2301/teamviewerd
tcp 0 0
0.0.0.0:57621 0.0.0.0:* LISTEN 28075/spotify
tcp 0 0 127.0.0.1:45112
0.0.0.0:* LISTEN 31454/Viber
tcp 0 0 0.0.0.0:220 0.0.0.0:* LISTEN 1233/sshd

tcp 0 0 127.0.0.1:4381 0.0.0.0:* LISTEN 28075/spotify
tcp 0 0
0.0.0.0:445 0.0.0.0:* LISTEN 2523/smbd
tcp6 0 0 :::139 :::* LISTEN 2523/smbd

tcp6 0 0 :::220 :::* LISTEN 1233/sshd
tcp6 0 0 :::445 :::* LISTEN
2523/smbd

tcp6 0 0 :::8000 :::* LISTEN 15002/apache2



the content of
/etc/nginx/proxy_params:



proxy_set_header
Host $http_host;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto
$scheme;


client_max_body_size
100M;
client_body_buffer_size 1m;
proxy_intercept_errors
on;
proxy_buffering on;
proxy_buffer_size
128k;
proxy_buffers 256 16k;
proxy_busy_buffers_size
256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size
0;
proxy_read_timeout
300;



can
someone please give me a hand and help me?


class="post-text" itemprop="text">
class="normal">Answer



after two
days i finally manage to solve my problem. thanks to this href="https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-16-04-server"
rel="nofollow noreferrer">page



i
ended up deleting the /etc/nginx/sites-available/default file and i have only one file
apache, just follow the instruction in the page and where it says enter your ip address
you can enter 127.0.0.1 if you are only trying to set it up for your local env. Also you
can skip 8 part and folloing parts as you dont need them. those are for setting up so
your server/com can be visible outsite of ur network so to call - Internet :)


Comments

Popular posts from this blog

linux - Awstats - outputting stats for merged Access_logs only producing stats for one server's log

I've been attempting this for two weeks and I've accessed countless number of sites on this issue and it seems there is something I'm not getting here and I'm at a lost. I manged to figure out how to merge logs from two servers together. (Taking care to only merge the matching domains together) The logs from the first server span from 15 Dec 2012 to 8 April 2014 The logs from the second server span from 2 Mar 2014 to 9 April 2014 I was able to successfully merge them using the logresolvemerge.pl script simply enermerating each log and > out_putting_it_to_file Looking at the two logs from each server the format seems exactly the same. The problem I'm having is producing the stats page for the logs. The command I've boiled it down to is /usr/share/awstats/tools/awstats_buildstaticpages.pl -configdir=/home/User/Documents/conf/ -config=example.com awstatsprog=/usr/share/awstats/wwwroot/cgi-bin/awstats.pl dir=/home/User/Documents/parced -month=all -year=all...

iLO 3 Firmware Update (HP Proliant DL380 G7)

The iLO web interface allows me to upload a .bin file ( Obtain the firmware image (.bin) file from the Online ROM Flash Component for HP Integrated Lights-Out. ) The iLO web interface redirects me to a page in the HP support website ( http://www.hp.com/go/iLO ) where I am supposed to find this .bin firmware, but no luck for me. The support website is a mess and very slow, badly categorized and generally unusable. Where can I find this .bin file? The only related link I am able to find asks me about my server operating system (what does this have to do with the iLO?!) and lets me download an .iso with no .bin file And also a related question: what is the latest iLO 3 version? (for Proliant DL380 G7, not sure if the iLO is tied to the server model)

hp proliant - Smart Array P822 with HBA Mode?

We get an HP DL360 G8 with an Smart Array P822 controller. On that controller will come a HP StorageWorks D2700 . Does anybody know, that it is possible to run the Smart Array P822 in HBA mode? I found only information about the P410i, who can run HBA. If this is not supported, what you think about the LSI 9207-8e controller? Will this fit good in that setup? The Hardware we get is used but all original from HP. The StorageWorks has 25 x 900 GB SAS 10K disks. Because the disks are not new I would like to use only 22 for raid6, and the rest for spare (I need to see if the disk count is optimal or not for zfs). It would be nice if I'm not stick to SAS in future. As OS I would like to install debian stretch with zfs 0.71 as file system and software raid. I have see that hp has an page for debian to. I would like to use hba mode because it is recommend, that zfs know at most as possible about the disk, and I'm independent from the raid controller. For us zfs have many benefits, ...