Apache2 Direkten IP Zugriff blockieren?
Hey, ich würde gerne den Zugriff auf meinen Webserver nur per Domain erlauben.
Wie mache ich dies?
Danke für eure Hilfe!
1 Antwort
![](https://images.gutefrage.net/media/user/TechPech1984/1632773764038_nmmslarge__12_0_519_519_b8bdbc8023c4e7722d66db9f2af2d5fd.png?v=1632773764000)
Nutzer, der sehr aktiv auf gutefrage ist
virtual host basteln und servername mit domain angeben .
https://httpd.apache.org/docs/2.4/vhosts/examples.html
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>
![](https://images.gutefrage.net/media/user/TechPech1984/1632773764038_nmmslarge__12_0_519_519_b8bdbc8023c4e7722d66db9f2af2d5fd.png?v=1632773764000)
TechPech1984
14.03.2022, 13:11
@Craftingtv
kann das sein das du ein default host hast in deiner http.conf ?
https://httpd.apache.org/docs/2.4/vhosts/examples.html
du kannst auch
Migrating a name-based vhost to an IP-based vhost
The name-based vhost with the hostname
www.example.org
(from our name-based example, setup 2) should get its own IP address. To avoid problems with name servers or proxies who cached the old IP address for the name-based vhost we want to provide both variants during a migration phase.
The solution is easy, because we can simply add the new IP address (
172.20.30.50
) to the
VirtualHost
directive.
Listen 80
ServerName www.example.com
DocumentRoot "/www/example1"
![](https://images.gutefrage.net/media/user/Craftingtv/1647259730666_nmmslarge__0_0_512_512_d0d8c4156c0806032a429d80fed1cb83.png?v=1647259731000)
@TechPech1984
Ich wüsste nich das ich eine http.conf erstellt habe/ Konfiguriert habe.
![](https://images.gutefrage.net/media/user/TechPech1984/1632773764038_nmmslarge__12_0_519_519_b8bdbc8023c4e7722d66db9f2af2d5fd.png?v=1632773764000)
TechPech1984
14.03.2022, 13:14
@Craftingtv
du hast nicht soviel ahnung von apache2 , erst gibts mal die http.conf oder apache.conf und die ruft dann erst die site-availible und mod-availible auf .
da steht sowas wie
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used. If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "D:/xampp/apache"
#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
#
# Uncomment and change the directory if mutexes are file-based and the default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
#
# Mutex default:logs
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
![](https://images.gutefrage.net/media/user/Craftingtv/1647259730666_nmmslarge__0_0_512_512_d0d8c4156c0806032a429d80fed1cb83.png?v=1647259731000)
![](https://images.gutefrage.net/media/user/Craftingtv/1647259730666_nmmslarge__0_0_512_512_d0d8c4156c0806032a429d80fed1cb83.png?v=1647259731000)
![](https://images.gutefrage.net/media/user/Craftingtv/1647259730666_nmmslarge__0_0_512_512_d0d8c4156c0806032a429d80fed1cb83.png?v=1647259731000)
@TechPech1984
Ich habs jetzt hinbekommen, danke dir!
![](https://images.gutefrage.net/media/user/TechPech1984/1632773764038_nmmslarge__12_0_519_519_b8bdbc8023c4e7722d66db9f2af2d5fd.png?v=1632773764000)
Vielen Dank für deine Antwort, genau das habe ich gemacht :). Trotzdem kann ich per IP Zdrauf kommen.