· 6 years ago · Nov 05, 2018, 03:34 PM
1location /wordpress/ {
2 proxy_pass http://192.168.1.12/;
3 proxy_set_header X-Forwarded-For $remote_addr;
4 proxy_set_header X-Real-IP $remote_addr;
5 proxy_set_header X-Forwarded-Proto $scheme;
6}
7
8server {
9listen 80 default_server;
10server_name 192.168.1.12;
11
12root /var/www/html/wordpress;
13index index.php index.html index.htm;
14
15access_log /var/log/nginx/default.access.log;
16error_log /var/log/nginx/default.error.log;
17
18## WordPress Perm links config ##
19location / {
20try_files $uri $uri/ /index.php?$args;
21}
22
23error_page 404 /404.html;
24error_page 500 502 503 504 /50x.html;
25location = /50x.html {
26root /usr/share/nginx/html;
27}
28
29location ~ .php$ {
30try_files $uri =404;
31fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
32fastcgi_index index.php;
33fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
34include fastcgi_params;
35}
36
37location ~ /.ht {
38deny all;
39}
40}
41
42if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||
43 (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {
44 $_SERVER['HTTPS'] = 'on';
45}
46
47function restrict_access_if_logged_out(){
48 global $wp;
49 if (!is_user_logged_in() && !is_home() && ($wp->query_vars['pagename'] != 'portail-identification') && ($wp->query_vars['pagename'] != 'portail-stagiaire') ){
50 wp_safe_redirect(wp_login_url(get_permalink()));
51 exit;
52 }
53}
54add_action( 'wp', 'restrict_access_if_logged_out', 3 );