Mall business-nginx-building domain name access environment 1 (reverse proxy configuration)

Forward proxy and reverse proxy

正向代理:如在进行开发时访问测试环境特定网络,隐藏客户端信息
Insert picture description here

反向代理:屏蔽内网服务器信息,负载均衡访问
Insert picture description here

Nginx configuration file

Insert picture description here
nginx.conf :

# 全局块:
# 配置影响 nginx 全局的指令。如:用户组, nginx进程pid存放路径,日志存放路径,配置文件引,允许生成worker process数等
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

# events块:
# 配置影响 nginx 服务器或与用户的网络连接。如:每个进程的最大连接数,选取哪种事件驱动模型处理连接请求,是否允许同时接受多个网路连接,开启多个网络连接序列化等。
events {
    
    
    worker_connections  1024;
}

# http块:
# 可以嵌套多个server,配置代理,缓存,日志定义等绝大多数功能和第三方模块的配置。如文件引入, mime-type定义,日志自定义,是否使用sendfile传输文件,连接超时时间,单连接请求数等。
http {
    
    
# http全局块
# 如upstream,错误页面,连接超时等
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

	# 会包含所有conf.d目录下的conf文件到当前cong文件中,所以我们可以在conf.d目录下新建一个conf文件来进行配置
    include /etc/nginx/conf.d/*.conf;
}

pafcmall.conf :

Copy a copy of default.conf to pafcmall.conf: cp default.conf pafcmall.conf

# server块
# 配置虚拟主机的相关参数,一个http中可以有多个server.
server {
    
    
    listen       80;
    #配置pafcmall的域名地址
    server_name  pafcmall.com;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

	# 配置请求的路由,以及各种页面的处理情况。
    location / {
    
    
        # 代理通过,将请求进行转交,要注意末尾要用 分号(;) 来进行结尾
        proxy_pass http://192.168.56.1:10000;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    
    
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    
    
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    
    
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    
    
    #    deny  all;
    #}
}

Nginx+Windows build domain name access environment

Let nginx help us with reverse proxy, all requests from the original pafcmall.com go to commodity services
Insert picture description here

先不使用网关, To directly configure nginxa reverse proxy to goods and services.

First set up nginx's self-startup in docker:
Insert picture description here

Modify the configuration file of nginx:

Check the nginx.conf file:
Insert picture description here
Insert picture description here

Configuration pafcmall.conffiles, first copy default.confthe file to pafcmall.confthe file:

    listen       80;
    #配置pafcmall的域名地址
    server_name  pafcmall.com;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
    
    
        #代理通过,将请求进行转交
        proxy_pass http://192.168.56.1:10000;
    }

Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/runewbie/article/details/106731581