server { listen 80; charset utf-8; server_name xxx.com www.xxx.com; if ($http_host !~ "^www.xxx.com$") { rewrite ^(.*) http://www.xxx.com$1 permanent; } location / { proxy_pass http://192.168.0.2:80; proxy_set_header Host $host; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }