如何配置Nginx仅为Azure应用服务上的wordpress提供https服务



我一直在处理Azure应用程序服务wordpress使用nginx,这是我正在使用的当前nginx配置,但它给了我多个"通过HTTPS加载,但请求的脚本不安全。错误,有办法解决吗?

upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
#proxy_cache cache;
#proxy_cache_valid 200 1s;
listen 8080;
listen [::]:8080;
root /home/site/wwwroot;
index  index.php index.html index.htm;
server_name  server.com; 
port_in_redirect off;

access_log   /home/data/access.log;
error_log    /home/data/error.log;


# Custom to allow large file uploads

client_max_body_size 256M;
# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /html/;
}
# Disable .git directory
location ~ /.git {
deny all;
access_log off;
log_not_found off;
}
# Add locations of phpmyadmin here.
location ~ [^/].php(/|$) {
fastcgi_split_path_info ^(.+?.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_connect_timeout         300; 
fastcgi_send_timeout           3600; 
fastcgi_read_timeout           3600;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$is_args$args =404;
}

if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ .php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

我从nginx和wordpress的页面尝试了多个配置。(没有一个工作准确的给我错误404和太多的重定向。)

<?php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS'] = 'on';

将此添加到wp配置和nginx的部分,使其在azure应用服务上工作

相关内容

  • 没有找到相关文章

最新更新