maddig
Goto Top

NGINX - Mit Domains vom LAN erreichen

Guten Abend,

nach meinem Umstieg auf nginx ist mir etwas sehr blödes aufgefallen.
Bisher war es immer mit z.b. Apache oder IIS so, das ich Vhosts erstellt habe und konnte auch vom LAN aus die einzelnen Hosts durch die Domain bzw Subdomains erreichen.

Mit Nginx ist es jedoch so, dass ich egal welche Domain oder Subdomain eingebe, immer auf einer Seite rauskomme. Das ist eine Reverse Proxy Site auf einen anderen Webserver mit Port 80.

Hab schon ein bisschen gegooglet und habe bisher nur Einträge im DNS bzw Routing von Windows gefunden. Da ich die Seiten aber mit mehreren PC erreichen will, will ich nicht bei jedem PC das nachtragen.

Gibt es eine Einstellmöglichkeit bei nginx? Weil bei Apache und IIS ging es ja auch immer "von alleine".

Ich hoffe ihr könnt mir helfen.

MFG

Content-Key: 313579

Url: https://administrator.de/contentid/313579

Printed on: April 19, 2024 at 18:04 o'clock

Member: StefanKittel
StefanKittel Aug 25, 2016 at 21:16:40 (UTC)
Goto Top
Hallo,

dann ist da was falsch.
Unter Nginx gibt es genau so vhosts.
Nur nicht in einzelnen Dateien sondern in einer großen.

Mit Hostname, Pfad und Einstellungen.

Stefan
Member: maddig
maddig Aug 26, 2016 at 05:03:49 (UTC)
Goto Top
Ja das funktioniert auch alles. Ich habe drei Sites und alle drei sind verlinkt in sites-enabled. Von außen läuft alles korrekt, nur vom LAN aus kann ich nicht mit den Domains/Subdomains darauf zugreifen.

Hier mal zwei von drei Sites und die nginx config.

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

events {
	worker_connections 768;
	# multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 2;
	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/*;
}

server {
        listen       80;
        server_name cloud.domain.de;

        # Redirect any HTTP request to HTTPS
        rewrite ^(.*) https://cloud.domain.de$1 permanent;
}


server {
	listen 443;
	#listen [::]:80;

	server_name cloud.domain.de;

	ssl on;
        ssl_certificate /root/1_domain.de_bundle.crt;
        ssl_certificate_key /root/domain.de.key;

        ssl_session_timeout 5m;

        ssl_protocols TLSv1;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
        ssl_prefer_server_ciphers on;

	root /var/www/cloud.domain.de/owncloud;
	index index.php;





	location / {
		try_files $uri $uri/ /index.php;
	}

	location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
}

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

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!  
	#
	# include snippets/snakeoil.conf;

	root /var/www/domain.de;

	# Add index.php to the list if you are using PHP
	index index.html index.php;

	server_name www.domain.de domain.de;

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

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	
		# With php5-cgi alone:
		#fastcgi_pass 127.0.0.1:9000;
		# With php5-fpm:
		fastcgi_pass unix:/var/run/php5-fpm.sock;
	}

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

Müsste eig alles passen. Nur wenn ich jetzt aus dem LAN auf domain.de oder auf cloud.domain.de gehe komme ich immer wieder auf dieser Port 80 Page raus. Egal mit welcher Domain.
Member: maddig
maddig Aug 26, 2016 updated at 11:12:36 (UTC)
Goto Top
Hier ist noch der Forumbeitrag den ich gefunden habe, der das selbe Problem hat wie ich.

http://serverfault.com/questions/582486/how-to-access-a-domain-or-its-s ...

Ist zwar schon vor 2 Jahren gepostet worden aber das Problem ist das gleiche.