server { listen 80; server_name baidu.com; location / { proxy_pass http://baidu.la/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }3修改完后,我们先执行:/usr/local/nginx/sbin/nginx -t 检查配置是否正常,如果显示:the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful 则正常,否则按错误提示修改配置,错误提示会精确到哪一行的。4最后执行 kill -HUP `cat /usr/local/nginx/logs/nginx.pid` 使配置生效,如果你的域名解析也生效了的话,应该就可以直接通过顶级域名访问了。