Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx 配置反向代理 #9

Open
huangshuwei opened this issue Dec 8, 2017 · 0 comments
Open

nginx 配置反向代理 #9

huangshuwei opened this issue Dec 8, 2017 · 0 comments
Labels

Comments

@huangshuwei
Copy link
Owner

huangshuwei commented Dec 8, 2017

前言

什么是反向代理呢,维基百科里原话是这么说的“反向代理是代理服务器的一种。它根据客户端的请求,从后端的服务器(如Web服务器)上获取资源,然后再将这些资源返回给客户端”

而正向代理相反,典型用途是为在防火墙内的局域网客户端提供访问Internet的途径。

配置

server {  
        listen       80;                                                        
        server_name  localhost;                                              

        location / {
            proxy_pass http://localhost:8080;
            proxy_set_header Host $host:$server_port;
        }
}

然后执行命令nginx -s reload 使配置生效。

这是访问 localhost 实质上回返回 localhost:8080 内容,当然为了看效果,最好本地搭建 localhost:8080 的站点。

--完--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant