• 确博日记
  • 工作时间:09:30 pm-06:24 pm

nginx反代(反向代理)设置教程

编辑nginx配置文件,nginx.conf,可以用记事本直接打开。

将默认的

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

修改为:

    server {
        listen       80; 
        server_name  www.domain.com;  #反代的域名

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
          proxy_pass  http://192.168.1.2:800;  #目标服务器IP和端口
          proxy_set_header Host $http_host;    #目标服务器主机头server_name

       proxy_set_header X-Forward-For $remote_addr;           

       index  index.html index.htm;
        }

  • 在线列表
    1589813

  • 在线提交