Nginx Problem Debian 7

08/04/2013 21:09 SEZonk#1
Guten Tag, ich kämpfe seit paar Std mit Nginx, alle Lösungen die ich im Internet gefunden habe, haben mir nicht weiter geholfen.

Im Error Log steht folgendes:
2013/08/04 14:20:46 [error] 2456#0: *7 connect() failed (111: Connection refused) while connecting to upstream, ....

2013/08/04 14:58:53 [error] 2456#0: *13 connect() failed (111: Connection refused) while connecting to upstream,
...


Wenn ich auf irgendeine Seite von mir gehe kommt immer:

502 Bad Gateway

Meine config
Code:
user www-data;
worker_processes 4;
pid /var/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-ffastream;

	##
	# 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/x-javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# nginx-naxsi config
	##
	# Uncomment it if you installed nginx-naxsi
	##

	#include /etc/nginx/naxsi_core.rules;

	##
	# nginx-passenger config
	##
	# Uncomment it if you installed nginx-passenger
	##
	
	#passenger_root /usr;
	#passenger_ruby /usr/bin/ruby;

	fastcgi_buffers 8 16k; 
       fastcgi_buffer_size 32k;
	
	#fdshuigfhs

	##
	# Virtual Host Configs
	##

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


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}
Ich hoffe mir kann jemand und bin für jede hilfreiche Antwort dankbar.

mfg
08/04/2013 21:12 Zypr#2
Ich nehme mal an, dass du nichts mit der vHosts Datei angestellt hast?

Poste den Inhalt von "/etc/nginx/sites-enabled/default", dann kann ich dir sagen wieso das nicht läuft.

Außerdem kannst du mal einen Blick in meine Signatur werfen.

Grüße
08/04/2013 21:17 SEZonk#3
Ja, ist bisschen viel, arbeite ich mich nachher mal durch, schon mal danke für den Tipp und deine Antwort.

Code:
# You may add here your
# server {
#	...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
	listen   80; ## listen for ipv4; this line is default and implied
	#listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

	root /var/www/webroot;
	index index.html index.htm;

	# Make site accessible from http://localhost/
	server_name http://localhost/;
	
 	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ /index.html;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}

	location /doc/ {
		alias /usr/share/doc/;
		autoindex off;
		allow 127.0.0.1;
		allow ::1;
		deny all;
	}

	location ~ \.php {
        	fastcgi_param  QUERY_STRING       $query_string;
        	fastcgi_param  REQUEST_METHOD     $request_method;
	        fastcgi_param  CONTENT_TYPE       $content_type;
	        fastcgi_param  CONTENT_LENGTH     $content_length;
 
	        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
	        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
	        fastcgi_param  REQUEST_URI        $request_uri;
	        fastcgi_param  DOCUMENT_URI       $document_uri;
	        fastcgi_param  DOCUMENT_ROOT      $document_root;
	        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
 
        	fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
	        fastcgi_param  SERVER_SOFTWARE    nginx;
 
        	fastcgi_param  REMOTE_ADDR        $remote_addr;
	        fastcgi_param  REMOTE_PORT        $remote_port;
	        fastcgi_param  SERVER_ADDR        $server_addr;
	        fastcgi_param  SERVER_PORT        $server_port;
	        fastcgi_param  SERVER_NAME        $server_name;
 
	        fastcgi_pass 127.0.0.1:9000;
	}

	# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
	#location /RequestDenied {
	#	proxy_pass http://127.0.0.1:8080;    
	#}

	#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/www;
	#}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	#location ~ \.php$ {
	#	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	#	# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
	#
	#	# With php5-cgi alone:
	#	fastcgi_pass 127.0.0.1:9000;
	#	# With php5-fpm:
	#	fastcgi_pass unix:/var/run/php5-fpm.sock;
	#	fastcgi_index index.php;
	#	include fastcgi_params;
	#}

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


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#	listen 8000;
#	listen somename:8080;
#	server_name somename alias another.alias;
#	root html;
#	index index.html index.htm;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}


# HTTPS server
#
#server {
#	listen 443;
#	server_name localhost;
#
#	root html;
#	index index.html index.htm;
#
#	ssl on;
#	ssl_certificate cert.pem;
#	ssl_certificate_key cert.key;
#
#	ssl_session_timeout 5m;
#
#	ssl_protocols SSLv3 TLSv1;
#	ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
#	ssl_prefer_server_ciphers on;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}
08/04/2013 21:19 Evolutio#4
Quote:
Originally Posted by SEZonk View Post
Ja, ist bisschen viel, arbeite ich mich nachher mal durch, schon mal danke für den Tipp und deine Antwort.

Code:
# You may add here your
# server {
#	...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
	listen   80; ## listen for ipv4; this line is default and implied
	#listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

	root /var/www/webroot;
	index index.html index.htm;

	# Make site accessible from http://localhost/
	server_name http://localhost/;
	
 	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ /index.html;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}

	location /doc/ {
		alias /usr/share/doc/;
		autoindex off;
		allow 127.0.0.1;
		allow ::1;
		deny all;
	}

	location ~ \.php {
        	fastcgi_param  QUERY_STRING       $query_string;
        	fastcgi_param  REQUEST_METHOD     $request_method;
	        fastcgi_param  CONTENT_TYPE       $content_type;
	        fastcgi_param  CONTENT_LENGTH     $content_length;
 
	        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
	        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
	        fastcgi_param  REQUEST_URI        $request_uri;
	        fastcgi_param  DOCUMENT_URI       $document_uri;
	        fastcgi_param  DOCUMENT_ROOT      $document_root;
	        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
 
        	fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
	        fastcgi_param  SERVER_SOFTWARE    nginx;
 
        	fastcgi_param  REMOTE_ADDR        $remote_addr;
	        fastcgi_param  REMOTE_PORT        $remote_port;
	        fastcgi_param  SERVER_ADDR        $server_addr;
	        fastcgi_param  SERVER_PORT        $server_port;
	        fastcgi_param  SERVER_NAME        $server_name;
 
	        fastcgi_pass 127.0.0.1:9000;
	}

	# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
	#location /RequestDenied {
	#	proxy_pass http://127.0.0.1:8080;    
	#}

	#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/www;
	#}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	#location ~ \.php$ {
	#	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	#	# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
	#
	#	# With php5-cgi alone:
	#	fastcgi_pass 127.0.0.1:9000;
	#	# With php5-fpm:
	#	fastcgi_pass unix:/var/run/php5-fpm.sock;
	#	fastcgi_index index.php;
	#	include fastcgi_params;
	#}

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


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#	listen 8000;
#	listen somename:8080;
#	server_name somename alias another.alias;
#	root html;
#	index index.html index.htm;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}


# HTTPS server
#
#server {
#	listen 443;
#	server_name localhost;
#
#	root html;
#	index index.html index.htm;
#
#	ssl on;
#	ssl_certificate cert.pem;
#	ssl_certificate_key cert.key;
#
#	ssl_session_timeout 5m;
#
#	ssl_protocols SSLv3 TLSv1;
#	ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
#	ssl_prefer_server_ciphers on;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
[COLOR="Red"]#}[/COLOR]


Kann es sein das die letzte "#}" das # zu viel ist ?
08/04/2013 21:27 SEZonk#5
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

Eigentlich nicht, weil 2 Klammer sind ja offen, dann müssen auch 2 wieder zu gemacht werden.

mfg
08/04/2013 21:36 Zypr#6
Du brauchst eigentlich nur den Punkt [#3 LEMP] aus dem Tutorial, je nachdem was du da benötigt.. oder du hälst dich einfach an den nginx Part.

Hast du denn die A-Records korrekt gesetzt? Jedenfalls muss die vHosts Datei bearbeitet werden, sonst wird da auch nichts laufen.

Grüße
08/04/2013 22:06 SEZonk#7
Habe sie nun bearbeitet, wie soll ich den A-Rekord setzen, habe noch keine Domain, ich wollte erstmal das alle von der IP ausgeht.

Habe es nach dein "TuT" gemacht und der Fehler ist immer noch.

mfg
08/04/2013 22:12 Zypr#8
Post mir mal die vHosts Datei, läuft nur nginx oder hast du davor Apache2 gehabt? Oder hast du ein minimal Image installiert?

Grüße
08/04/2013 22:39 SEZonk#9
Appache 2 war schon vorher drauf.


PHP Code:
server 
    
listen    IPzensiert:80 default; 
    
server_name    IPzensiert *.IPzensiert;
    
access_log      /var/www/log/access.log combined;
        
error_log    /var/www/log/error.log error;
    
root     /var/www/htdocs/;
        
        
location / {
    
index    index.php index.html index.htm;
    
try_files $uri $uri/ @rewrites;
    }

    
location ~ \.php$ {
        
try_files $uri =404;
        
fastcgi_split_path_info ^(.+\.php)(/.+)$;
        
fastcgi_index index.php;
        
fastcgi_pass unix:/var/run/php5-fpm.socket;
        
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /
etc/nginx/fastcgi_params;
    }

    
error_page 404 /index.php;
    
autoindex off;

    
## Only allow these request methods ##
    
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
        return 
444;
        }

    
## Block download agents ##
    
if ($http_user_agent ~* (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) ) {
    return 
403;
    }


    
## Deny certain Referers ##
        
if ( $http_referer ~* (babes|forsale|girl|jewelry|love|nudit|organic|poker|porn|sex|teen) ) {
        return 
403;
    }

    
## Directory Protection ##
    
location ~ /\. { 
    
deny  all
    }

    
## sample ##
        #location /zbblock/ {
    #deny all;
    #return 404;
    #}


    ## RESSOURCES ##
    
location ~ \.(?:ico|png|jpe?g|css|js)$ {
    
expires 31d;        
    
add_header Pragma "public";
    
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }
    
    
location ~ \.(php~|php.bak)$ {
        
deny all;
        return 
404;
    }

    
## REWRITES ##
    
location ~ ^/(\d+)/$ {
    return 
301 /?p=$1;
    }

    
location @rewrites {
    
rewrite ^ /index.php last;
    }

08/04/2013 22:49 Zypr#10
Dann stört dich Apache noch, du musst es löschen:

Suchen kannst du nach allen Apache2 Paketen wie folgt:
Code:
dpkg -l | grep apache
Anschließend kannst du jedes Paket mit folgendem Befehl löschen:
Code:
aptitude purge PAKETNAME
Lösch einfach alles, was nach apache aussieht. Anschließend kannst du nginx starten:
Code:
service nginx start
Grüße
08/04/2013 23:18 SEZonk#11
Habe ich gemacht, alles entfernt.

Aber der Fehler trifft immer noch auf.

"502 Bad Gateway"

mfg
08/04/2013 23:22 Zypr#12
Hast du PHP-FPM installiert? Wenn du die Config von mir 1:1 übernommen hast, brauchst du das..

Bei dir steht nämlich:

fastcgi_pass unix:/var/run/php5-fpm.socket;

Lies dir Punkt #3.3 PHP nochmal genauer durch.

Grüße
08/05/2013 00:13 SEZonk#13
Ich habe es mir angeguckt, ich müsste jetzt alles gleich haben.

Neugestartet habe ich auch, sehe aber keine Veränderung.

Haben sie vielleicht Teamviewer und können einmal rüber schauen ?.

mfg