直接贴代码
nginx
分发文件
server { listen 80;#监听端口 server_name 域名;#域名 location / { proxy_pass 代理地址; #Proxy Settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
代理文件 server { listen 端口;#监听端口 server_name 域名;#域名 index index.html index.htm index.php; root 站点目录;#站点目录 location / { try_files $uri $uri/ /?$args; } location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 15d; } access_log off; }
项目文件 wp-config.php
上面添加
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) { $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST']; }