nginx.conf配置如下:
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;client_max_body_size 1000m;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopushon;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;upstream myserviceAPI{ip_hash;server 192.168.1.2:8011;server 192.168.1.3:8011;}server {listen 8080 default;server_name 192.168.1.1;if ($http_Host !~* "^(192.168.1.1:8080)$" ){return 403;} #预警后端location /service {proxy_pass http://myserviceAPI/service;proxy_connect_timeout 1;add_header Content-Security-Policy: default-src=self;add_header X-Xss-Protection: 1;add_header X-Xss-Protection: mod=block;add_header X-Content-Type-Options: nosniff;}}}