如何使用' proxy_pass'?

时间:2016-07-30 16:03:11

标签: javascript java apache nginx server

worker_processes 1;

events {
    worker_connections  1024;
}

http {
    server{
        listen 3001;
        server_name localhost;

        location /{
            proxy_pass http://localhost:3002;

            add_header 'Access-Control-Allow-Origin' "$http_origin";
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            return 200 'OK';

        }
    }
}

我写的就是这样接收' http://localhost:3001'并发送给' http://localhost:3002'。收到做得好。总是返回200并确定 但是,我的http://localhost:3002'没有收到任何请求消息。 我想,打开本地主机:3001'在我的浏览器中,' localhost:3002'什么都收到 当然,当我打开localhost:3002'时,我检查了我的localhost:3002收到了一些消息。 我的代码错了吗?

0 个答案:

没有答案
相关问题