Source code

จาก วิกิพีเดียว กองแผนงาน มช.
รุ่นแก้ไขเมื่อ 02:17, 17 กรกฎาคม 2567 โดย Admin (คุย | ส่วนร่วม) (สร้างหน้าด้วย "EDIT: Resolution and working configs: wp-config.php: Add the lines below to wp-config.php to force https (as per the link here)... Note that in order for this to work for me, I had to put the lines at the top of my wp-config.php config file. if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||      (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {       $_SERVER['HTTPS'] = 'on'; } My Nginx reverse proxy config on my separate Nginx server:...")
(ต่าง) ←รุ่นแก้ไขก่อนหน้า | รุ่นแก้ไขล่าสุด (ต่าง) | รุ่นแก้ไขถัดไป→ (ต่าง)
ไปยังการนำทาง ไปยังการค้นหา

EDIT: Resolution and working configs:

wp-config.php: Add the lines below to wp-config.php to force https (as per the link here)... Note that in order for this to work for me, I had to put the lines at the top of my wp-config.php config file.

if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||

     (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {

      $_SERVER['HTTPS'] = 'on';

}

My Nginx reverse proxy config on my separate Nginx server:

server {

    listen 443 ssl;

    server_name foo.bar www.foo.bar;

    location / {

        proxy_pass http://10.0.80.32/;

        proxy_set_header X-Forwarded-Host $host;

proxy_set_header X-Forwarded-Server $host;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $host;

    }

    ssl_certificate /etc/letsencrypt/live/foo.bar/fullchain.pem;

    ssl_certificate_key /etc/letsencrypt/live/foo.bar/privkey.pem;

    include /etc/letsencrypt/options-ssl-nginx.conf;

    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

}

server {

    server_name foo.bar www.foo.bar;

    return 301 https://foo.bar$request_uri;

}