【发布时间】:2016-09-14 11:47:16
【问题描述】:
服务器设置:
- VPS
- Plesk 12.5
- Centos 7
- NGINX 作为 Apache 2.4 的反向代理
- NGINX 配置路径:/etc/nginx/nginx.conf
Plesk 提供了一个 GUI Apache & nginx 设置对话框,但无法从那里接受服务器块。
我尝试了以下方法及其几种变体,但均未成功:
server {
server_name xx.xx.xx.xx;
return 301 https://domain.com$request_uri
}
这是我们正在尝试做的另一个示例,需要知道将代码放置在哪里,以便 NGINX 读取并遵守指令以执行。
server {
server_name newdomain.com www.newdomain.com;
# ngx_pagespeed & ngx_pagespeed handler
#include /usr/local/nginx/conf/pagespeed.conf;
#include /usr/local/nginx/conf/pagespeedhandler.conf;
#include /usr/local/nginx/conf/pagespeedstatslog.conf;
# limit_conn limit_per_ip 16;
# ssi on;
access_log /home/nginx/domains/newdomain.com/log/access.log combined buffer=32k;
error_log /home/nginx/domains/newdomain.com/log/error.log;
root /home/nginx/domains/newdomain.com/public;
location / {
# block common exploits, sql injections etc
#include /usr/local/nginx/conf/block.conf;
# Enables directory listings when index file not found
#autoindex on;
}
location /forums {
try_files $uri $uri/ /index.php;
}
location ~^(/forums/page/).*(\.php)$ {
try_files $uri $uri/ /index.php;
}
# Mask fake admin directory
location ~^/forums/admin/(.*)$ {
deny all;
}
# Secure real admin directory
location ~^(/forums/mynewadmin/).*(\.php) {
#allow 127.0.0.1;
#deny all;
#auth_basic "Restricted Area";
#auth_basic_user_file $document_root/forums/mynewadmin/.htpasswd;
include /usr/local/nginx/conf/php.conf;
}
# IP.Board PHP/CGI Protection
location ~^(/forums/uploads/).*(\.php)$ {
deny all;
}
location ~^(/forums/hooks/).*(\.php)$ {
deny all;
}
location ~^(/forums/cache/).*(\.php)$ {
deny all;
}
location ~^(/forums/screenshots/).*(\.php)$ {
deny all;
}
location ~^(/forums/downloads/).*(\.php)$ {
deny all;
}
location ~^(/forums/blog/).*(\.php)$ {
deny all;
}
location ~^(/forums/public/style_).*(\.php)$ {
deny all;
}
include /usr/local/nginx/conf/staticfiles.conf;
include /usr/local/nginx/conf/php.conf;
include /usr/local/nginx/conf/drop.conf;
#include /usr/local/nginx/conf/errorpage.conf;
}
在这种情况下,我需要在哪里放置这个或类似的定向,以将所有直接 IP 流量定向到域名?到目前为止,我已经尝试将 sn-p 放在各种 NGINX 配置文件中,但均未成功。
谢谢。
【问题讨论】:
标签: apache nginx vps centos7 plesk