Bloquer le port 80/443 sur deux de mes sous-domaines | Apache 2.4.25 | Debian 9

Tags: #<Tag:0x00007f63f22fd368>

Bonjour,
Je souhaiterai bloquer le port 80/443 sur mon sous-domaine play.lapiscraft.fr
Je n’aime pas laisser le port 80/443 car ils ne serviront à rien pour apache.
Et ca ne ferais pas très professionnel…
Si possible avoir le meme résultat que quand on tape mc.hypixel.net

Je suis sous Debian 9, Apache 2.4.25
Merci de me répondre au plus vite…

-Matteo

EDIT: J’ai supprimé les sous-domaines au lieu de me casser le chou…

1 J'aime

Tu ne peux pas.
Un port, ça se bloque sur une adresse ip, pas sur un nom de domaine.
Tu peux par contre choisir, dans ta configuration de virtual host apache, que ton nom de domaine n’écoute que sur un autre port que 80/443, mais refuser l’envoi de paquets http sur la base de ce qu’il y a dedans (l’adresse d’un site internet), tu peux pas.

Ah ben tu as une réponse la plus rapide qui soit maitre:
on ne peut pas faire ce que tu dis.

Rebonjour, pourtant fail2ban (paquet de debian) bloque bien des noms de domaines.

Juste toi qui sais pas faire ca sur debian

Bonjour,

Il faut expliquer clairement ce que tu veux bloquer et quelle est ta configuration. Pour l’instant c’est plutôt obscur…

Les port 80 et 443 sont les ports standards pour les protocoles HTTP et HTTPS. Si tu les fermes, personne n’aura plus accès a ton serveur web.
Tu peut mettre ton serveur en écoute sur d’autres ports comme l’a expliqué @mattotop.

Cela ne veut rien dire… Il faut que tu expliques.
Si tu veux bloquer l’accès à un site web correspondant à ce domaine, il y a des tas de manières de le faire, à commencer par ne pas avoir de service HTTP(S) qui réponde pour ce domaine.

Non, pas à ma connaissance. Fail2ban utilise iptables ou nftables pour bloquer des adresses IP.

Non. fail2ban ne bloque que des ips, gamin.

Pour autant que je sache, fail2ban sait bloquer des ips venant de domaines déclarés en blocklist, mais il ne bloque pas des ips en fonction de ce qu’elles font comme requète http (c’est à dire en fonction du domaine géré par le serveur web auquel sont destinés les paquets).

Non.
C’est toi qui ne comprends pas assez bien de quoi tu parles, ou pire, la langue, pour choisir les bons mots pour poser des questions.

Car je suis sur que ce que tu veux obtenir est possible, je n’en ai aucun doute…
Mais ce que tu demandes avec tes mots mal choisi, à savoir bloquer des ports en fonction du domaine http auquel on accède, est impossible à ma connaissance (disons que je vois comment on pourrait le faire, mais ça n’est fait par aucun soft pour autant que je sache et il faudrait le coder).

Donc: apprends à parler et à lire, évite de mépriser les gens qui ne font que te répondre pour t’aider, ça améliorera l’ambiance du forum.

1 J'aime

@mattotop Tu pourrais parler mieux? Et @anon70622873 j’ai oublié de preciser que c’est bloqué via iptables

Je vais donner mon fichier vhost:

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    <If "%{HTTP_HOST} != 'lapiscraft.fr'">
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    </If>
    <ElseIf "%{HTTP_HOST} == 'lapiscraft.fr'">
        RewriteRule (.*) https://www.lapiscraft.fr%{REQUEST_URI}
    </ElseIf>
</VirtualHost>
<VirtualHost *:443>
    ServerAdmin web-error@lapiscraft.fr
    DocumentRoot /var/www/lapiscraft.fr
    ServerName lapiscraft.fr
    ServerAlias www.lapiscraft.fr
    <If "%{HTTP_HOST} == 'play.lapiscraft.fr'">
        Redirect permanent / https://www.lapiscraft.fr/
    </If> (balise fermée)
    <If "%{HTTP_HOST} == 'mail.lapiscraft.fr'">
        Redirect permanent / https://www.lapiscraft.fr/
    </If> (balise fermée)
    ErrorLog ${APACHE_LOG_DIR}/lapiscraft.fr-error.log
    CustomLog ${APACHE_LOG_DIR}/lapiscraft.fr-access.log combined
    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/lapiscraft.fr.cer
    SSLCertificateKeyFile /etc/ssl/private/lapiscraft.fr.key
</VirtualHost>

Qu’est-ce qui est bloqué via iptables ? Montre-nous ta configuration iptables.
Si tu bloques les ports 80 et 443 ton serveur web n’est plus accessible du tout. Donc je ne comprends pas ce que tu bloques.

Si tu ne veux pas que tes domaines mail.lapiscraft.fr et play.lapiscraft.fr soient pas accessibles sur le web, supprimes tes redirections et réécritures dans ta configuration Apache et fait en sorte que ce soit l’hôte virtuel par défaut qui réponde pour ces domaines en ne renvoyant rien, ou une erreur 404 ou 403.
Tu peux aussi créer un hôte virtuel spécifique pour ces domaines.

Non, toi.
Tu me traites d’incompétent ce qui est mal me parler, et je te renvoie le compliment juste parce que contrairement à ce que tu affirme pour moi gratuitement, pour toi l’incompétence est factuelle dés les premières lignes de ta demande et confirmée à chacun de tes posts.
J’énonce des faits visibles (tu ne comprends pas de quoi tu parles) et ce n’est pas parler bien ou mal que de le dire.
Quant au “gamin” que j’ai utilisé, c’est justement pour te remettre à ta place aprés ton arrivée qui amorce sur un “vous avez intérêt à me répondre vite fait” et que tu en rabattes sur ton ton prétentieux.
Si tu appelles ça “parler mal”, tu n’as pas fini de souffrir.

Sur ce, bon courage aux autres pour déchiffrer ce que tu dis et comprendre ton problème, ça sera sans moi.

Bon en tout cas 0/20 une personne dont je ne citerais pas le nom.

Bon on va se détendre s’il vous plait.

@SkinDePewDiePie

tu peux me montrer écrit noir sur blanc que tu peux bloquer un nom de domaine avec fail2ban ?

@anon70622873 et @mattotop t’ont déjà donné des pistes pour isoler ton domaine.

@Clochette Sauf que @mattotop me soule, et la solution de @anon70622873 ne me vas pas: j’ai supprimé l’vhost par défaut --’

Voici le résultat de cette commande!

root@matteo:/home/lapiscraft# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
f2b-sshd   tcp  --  anywhere             anywhere             multiport dports ssh
DROP       all  --  matteo               anywhere
DROP       tcp  --  matteo               anywhere             tcp dpt:https
DROP       tcp  --  matteo               anywhere             tcp dpt:https
DROP       tcp  --  matteo               anywhere             tcp dpt:https
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     tcp  --  anywhere             default              tcp dpt:http reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             default              udp dpt:80 reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             matteo               tcp dpt:http reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             matteo               udp dpt:80 reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             matteo               udp dpt:80 reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             matteo               udp dpt:80 reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             matteo               udp dpt:80 reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             matteo               udp dpt:80 reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
Chain f2b-sshd (1 references)
target     prot opt source               destination
REJECT     all  --  95.85.62.139         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  95.58.194.141.megaline.telecom.kz  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  ns303460.ip-94-23-208.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  host.infinitesoftsolutions.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  92.62.139.103        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  91.250.242.12        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  marylou.nos-oignons.net  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  algrothendieck.nos-oignons.net  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  lputeaux-657-1-261-16.w80-15.abo.wanadoo.fr  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  144.ip-79-137-84.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  cpe-74-141-89-35.neo.res.rr.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  68.183.192.163       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  68.183.105.52        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor.t-3.net          anywhere             reject-with icmp-port-unreachable
REJECT     all  --  simmu4-84-53.utaonline.at  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  62.102.148.69        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  62.102.148.68        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  59.9.223.244         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  105.ip-54-36-189.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  52.178.79.114        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  106.ip-51-75-26.eu   anywhere             reject-with icmp-port-unreachable
REJECT     all  --  124.ip-51-75-123.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  215.ip-51-255-174.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit.cf          anywhere             reject-with icmp-port-unreachable
REJECT     all  --  49.88.112.63         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit.critical.cat  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  crushdigital.co.uk   anywhere             reject-with icmp-port-unreachable
REJECT     all  --  46.101.235.214       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  45.55.35.40          anywhere             reject-with icmp-port-unreachable
REJECT     all  --  45.55.142.207        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  43.227.66.159        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  42.115.138.81        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  42.112.185.242       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  41-213-216-242.zeop.re  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  37.114.182.223       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit.eecs.umich.edu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  23.129.64.215        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  208.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  207.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  205.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  201.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  200.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  196.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  195.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  192.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  191.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  189.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  187.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  184.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  180.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  154.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  152.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  100.emeraldonion.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  221.156.116.51       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  218.92.0.173         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  218.92.0.155         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  nortor3.nortor.no    anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit-node.7by7.de  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  noobs.at.lamers.zone  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  211.159.149.29       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  210.212.249.228      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  209.205.217.210      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  lv1.nixnet.xyz       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  206.189.188.223      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  206.189.137.113      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  cs-tor.bu.edu        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  203.121.116.11       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  mail.wantech.hk      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  202.112.237.228      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  201.47.158.130.static.host.gvt.net.br  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor.les.net          anywhere             reject-with icmp-port-unreachable
REJECT     all  --  exit.tor.uwaterloo.ca  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  zrh-exit.privateinternetaccess.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  140.ip-193-70-37.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  193.201.224.232      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  192-3-204-78-host.pincel.mx  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  191.34.162.186.dynamic.adsl.gvt.net.br  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  188.131.176.201      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  187-101-235-10.dsl.telesp.net.br  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  185.216.132.15       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor3.digineo.de      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  geri.enn.lu          anywhere             reject-with icmp-port-unreachable
REJECT     all  --  181.48.95.130        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  178.62.33.138        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  178.62.117.82        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  178.128.195.6        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  mm-177-102-122-178.mgts.dynamic.pppoe.byfly.by  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  network-ppp-144-27.prtelecom.com.br  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  175.211.112.250      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit5-readme.dfri.se  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit3-readme.dfri.se  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit0-readme.dfri.se  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  170.210.52.126       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  165.231.13.13        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  165.227.112.164      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  165.22.21.221        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  165.22.142.176       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  soeinfeuerballjunge.de  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  163-172-59-189.rev.poneytelecom.eu  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  wiebe.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  korematsu.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  perry.fellwock.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  phoolandevi.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  billsf.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  kunstler.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  jaffer.tor-exit.calyxinstitute.org  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  159.65.54.221        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  187449.cloudwaysapps.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  142.93.85.35         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  142.93.39.29         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  142.93.101.13        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  static.vnpt.vn       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  139.59.59.187        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  139.59.180.53        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  labs2.armadilloamarillo.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  138.197.105.79       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  129.211.11.107       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  icech.moneyzdv24.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  121.142.111.230      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  118.25.128.19        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  116.196.81.5         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  110.77.246.200       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  107-213-136-221.lightspeed.tukrga.sbcglobal.net  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  107.170.124.97       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  106.248.249.26       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  106.13.165.13        anywhere             reject-with icmp-port-unreachable
REJECT     all  --  106.12.28.10         anywhere             reject-with icmp-port-unreachable
REJECT     all  --  106.12.134.133       anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit-node-tpc1   anywhere             reject-with icmp-port-unreachable
REJECT     all  --  tor-exit-node-tpc2   anywhere             reject-with icmp-port-unreachable
REJECT     all  --  104-237-253-195-host.colocrossing.com  anywhere             reject-with icmp-port-unreachable
REJECT     all  --  103.79.141.158       anywhere             reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere

Et je pense supprimer les

REJECT tcp - anywhere default tcp dpt:http reject-with icmp-port-unreachable

Mais ce que je comprends pas meme avec ses lignes j’arrive à accèder à ma machine via HTTP(S). Depuis une machine externe, mais sur telnet j’y arrive pas, bon je reset iptables et je vous dis le resultat.

Je n’ai donné aucune solution, juste des pistes de réflexion sur ta configuration.

Tu n’as toujours pas expliqué clairement ce que tu veux faire vis à vis de ces domaines.

Explique nous aussi tes règles iptables avec de préférence un retour de :

iptables -L -n

Car on ne sait pas à quoi correspond « matteo » et iptables filtre sur les IP par sur les domaines. On te l’a déjà dit.
Là j’ai vaguement l’impression que tu rejettes les paquets entrants provenant de ton propre serveur :laughing:

Plutôt avec iptables-save dont la sortie est plus complète et lisible.

1 J'aime

Bonjour,

Les ports 80 et 443 sont utilisés et donc ouverts sur des serveurs du monde entier pour répondre à des requêtes HTTP. C’est le cas de l’intégralité des GAFAM donc parler de professionnalisme…

Bien monseigneur, il vous faudra autre chose ?

Personnellement pour éviter que mon nginx serve n’importe quoi lorsqu’un vhost n’existe pas, j’utilise ceci :

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        return 444;
}

Va falloir revoir ta façon de t’exprimer envers des gens qui ne te connaissent pas et qui malgré ton langage essayent tout de même de t’aider.

@sk4hrr Juste merci, sauf que je suis pas sur nginx! T’aurais pu lire mon problème au moins.

1 J'aime

La deuxième personne a qui tu réponds mal je serai toi je prendrai des pincettes la prochaine fois avant d’appuyer sur le bouton envoi.