encore un peu de relecture
This commit is contained in:
parent
0ef8598e36
commit
6c9fbd98cc
|
@ -206,9 +206,8 @@ Nginx peut aussi agir comme Reverse Proxy. On utilisera alors la directive **pro
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://localhost:8080;
|
proxy_pass http://127.0.0.1:8080;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $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-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
@ -322,43 +321,21 @@ location ~* \.(eot|ttf|woff)$ {
|
||||||
|
|
||||||
### http_user_agent
|
### http_user_agent
|
||||||
|
|
||||||
|
On peut définir des actions en fonction du User-Agent :
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
if ($http_user_agent ~* (DotBot|Cliqzbot|AhrefsBot|SemrushBot)) {
|
if ($http_user_agent ~* (DotBot|Cliqzbot|AhrefsBot|SemrushBot)) {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Si on doit bloquer un user-agent avec des espaces dans son nom, une solution est d’échapper les espaces avec des backslash comme ceci :
|
> *Note* : Si l'on doit bloquer un User-Agent avec des espaces dans son nom, une solution est d’échapper les espaces :
|
||||||
|
>
|
||||||
~~~
|
> ~~~
|
||||||
if ($http_user_agent ~* (DotBot|Cliqzbot|AhrefsBot|SemrushBot|Go\ 1\.1\ package\ http)) {
|
> if ($http_user_agent ~* (DotBot|Cliqzbot|AhrefsBot|SemrushBot|Go\ 1\.1\ package\ http)) {
|
||||||
return 404;
|
> return 404;
|
||||||
}
|
> }
|
||||||
~~~
|
> ~~~
|
||||||
|
|
||||||
### error_page
|
|
||||||
|
|
||||||
On peut avoir une page personnalisée selon le code d'erreur HTTP renvoyé.
|
|
||||||
Contrairement à apache, on ne pourra indiquer une conf général à inclure qui s'appliquera pour tous les vhosts, mais il faudra ajouter l'include sur tous les fichiers de confs des vhosts.
|
|
||||||
|
|
||||||
Fichier de conf général */etc/nginx/error.conf*
|
|
||||||
|
|
||||||
~~~
|
|
||||||
location /YYYYYY/ {
|
|
||||||
alias /var/www/;
|
|
||||||
index page.html;
|
|
||||||
}
|
|
||||||
error_page XXX /YYYYYY/;
|
|
||||||
|
|
||||||
~~~
|
|
||||||
|
|
||||||
Remplacer XXX par le code erreur HTTP souhaité et YYYYY par le nom de _Location_ souhaité (URL) - vu que global à tous les vhosts, prendre une chaîne aléatoire.
|
|
||||||
|
|
||||||
Et pour chaque conf des vhosts `/etc/nginx/sites-enabled/*.conf` :
|
|
||||||
|
|
||||||
~~~
|
|
||||||
include /etc/nginx/error.conf;
|
|
||||||
~~~
|
|
||||||
|
|
||||||
### more_set_headers
|
### more_set_headers
|
||||||
|
|
||||||
|
@ -412,6 +389,14 @@ $ mv /home/example/www/{,_}maintenance.html
|
||||||
|
|
||||||
## Monitoring
|
## Monitoring
|
||||||
|
|
||||||
|
### log2mail
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
### apachetop
|
||||||
|
|
||||||
|
**apachetop** peut servir aussi pour Nginx, voir [HowtoApache#apachetop]()
|
||||||
|
|
||||||
### Munin
|
### Munin
|
||||||
|
|
||||||
Ajouter dans la configuration Nginx :
|
Ajouter dans la configuration Nginx :
|
||||||
|
@ -541,12 +526,26 @@ listen 0.0.0.0:443 ssl http2;
|
||||||
|
|
||||||
<https://nginxconfig.io/>
|
<https://nginxconfig.io/>
|
||||||
|
|
||||||
|
### Page personnalisée lors code erreur HTTP
|
||||||
|
|
||||||
|
On peut avoir une page personnalisée selon le code d'erreur HTTP renvoyé.
|
||||||
|
|
||||||
|
~~~
|
||||||
|
location /YYYYYY/ {
|
||||||
|
alias /var/wwwerror/;
|
||||||
|
index page.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 403 /YYYYYY/;
|
||||||
|
~~~
|
||||||
|
|
||||||
|
|
||||||
### Comment prononcer Nginx ?
|
### Comment prononcer Nginx ?
|
||||||
|
|
||||||
C'est la première question de la [FAQ officielle](https://www.nginx.com/resources/wiki/community/faq/#how-do-you-pronounce-nginx) du projet. Pour les francophones, voilà notre astuce :
|
C'est la première question de la [FAQ officielle](https://www.nginx.com/resources/wiki/community/faq/#how-do-you-pronounce-nginx) du projet. Pour les francophones, voilà notre astuce :
|
||||||
|
|
||||||
* D'abord le **N** se prononce tout seul, comme dans « haine ».
|
* D'abord le **N** se prononce tout seul, comme dans « haine ».
|
||||||
* Puis **gin**, comme dans « imagine », ou « j'ai enfilé mon jean ».
|
* Puis **gin**, comme dans « imagine », ou « j'ai enfilé mon jean ».
|
||||||
* Et enfin **x**, comme dans « j'habite à Aix ».
|
* Et enfin **x**, comme dans « j'habite à Aix ».
|
||||||
|
|
||||||
### .htaccess ?
|
### .htaccess ?
|
||||||
|
|
Loading…
Reference in a new issue