444 nginx_nginx新增域名

#### -*-mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-

### Block all illegal host headers. Taken from a discussion on nginx

### forums. Cf. http://forum.nginx.org/read.php?2,3482,3518 following

### a suggestion by Maxim Dounin. Also suggested in

### http://nginx.org/en/docs/http/request_processing.html#how_to_prevent_undefined_server_names.

map $http_upgrade $connection_upgrade {

default upgrade;

'' close;

}

###在自己扩展的站点配置中,复制下行,并添加对应的映射项,例如从api.XXX.XXX到www.XXX.XXXX。

map $host $upstream_host {

default $host;

# api.example.com www.example.com;

}

# caching options

proxy_cache_path /home/httpd/cache/nginx levels=1:2 keys_zone=wware-cache:8m max_size=1000m inactive=600m;

proxy_temp_path /home/httpd/cache/tmp;

server {

large_client_header_buffers 4 32k;

listen 80 default_server deferred; # IPv4

#error_log /var/log/nginx/error_debug.log debug;

#error_log /var/log/nginx/error.log;

#access_log /var/log/nginx/access.$http_host.log;

#we put all log in access.log, so we can monitor it in wide.

access_log /var/log/nginx/access.log;

#301 redirect if http_host is a main domain(i.e:wware.org)

#abandoned solution of not starting with www: (if ($http_host !~* ^www\.){

if ($http_host ~* ^[a-zA-Z0-9-_]+\.\w+$) {

return 301 $scheme://www.$http_host$request_uri;

}

## Socket options can only be specified once, hence the different

## address for the 'default' server.

# listen [fe80::202:b3ff:fe1e:8328]:80 default_server ipv6only=on; # IPv6

#root /home/httpd/www/$http_host;

root /home/httpd/data/fs/static/$host;

#Specify a charset

charset utf-8;

index index.html index.htm;

#server_name $http_host;

server_name _;

## See the blacklist.conf file at the parent dir: /etc/nginx.

## Deny access based on the User-Agent header.

if ($bad_bot) {

return 444;

}

## Deny access based on the Referer header.

if ($bad_referer) {

return 444;

}

## Protection against illegal HTTP methods. Out of the box only HEAD,

## GET and POST are allowed.

if ($not_allowed_method) {

return 405;

}

## If you're using a Nginx version greater or equal to 1.1.4 then

## you can use keep alive connections to the upstream be it

## FastCGI or Apache. If that's not the case comment out the line below.

#fastcgi_keep_conn on; # keep alive to the FCGI upstream

## @FIXME: shall we redirect error page to nodejs for more sophisticated processing???

error_page 500 502 503 504 /500.html;

error_page 404 /404.html;

################################################################

### Configuration for pagespeed.

################################################################

include apps/pagespeed.conf;

################################################################

### Configuration for standard WWARE.

################################################################

include apps/wware.conf;

location /http-bind {

log_not_found off;

access_log off;

proxy_buffering off;

gzip_static on;

gzip_vary on;

tcp_nodelay on;

keepalive_timeout 55;

proxy_pass http://127.0.0.1:7070;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-URL $request_uri;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection $connection_upgrade;

}

location = /favicon.ico {

log_not_found off;

access_log off;

gzip_static on;

gzip_vary on;

expires 30d;

add_header Cache-Control "public, must-revalidate, post-check=0, pre-check=0";

}

## Including the Nginx stub status page for having stats about

## Nginx activity: http://wiki.nginx.org/HttpStubStatusModule.

include nginx_status_vhost.conf;

}

修改完配置文件后,重启服务bash /home/httpd/wware/tools/restartserver.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值