您现在的位置:首页 > 工具软件 > 软件使用

nginx反向代理配置,https反向代理配置(Reverse Proxy),nginx ipv6反向代理配置

简单介绍nginx反向代理配置,https反向代理配置(Reverse Proxy),和ipv6网络环境下的反向代理配置。

1.nginx http反向代理配置(IPv4)

找到nginx.conf配置文件,修改server配置如下:
    server {
        listen     80;
        server_name  www.yunweiriji.com;

        location / {
            proxy_pass http://yunweiriji.com/;
            index  index.html index.htm index.jsp;
        }
    }
通过该配置,代理访问http://yunweiriji.com/

2.nginx http反向代理配置(IPv6)

    server {
        listen     [::]:80;
        server_name  www.yunweiriji.com;

        location / {
            proxy_pass http://www.yunweiriji.com/;
            index  index.html index.htm index.jsp;
        }
    }
通过该配置,可以实现网站无缝支持IPv6访问。不用更改源网站任何配置。

3.nginx https(ssl)反向代理配置(IPv4)

    server {
        listen       443 ssl;
        server_name  www.yunweiriji.com;

        ssl_certificate      D://nginx-1.16.1//SSL//server.pem;
        ssl_certificate_key  D://nginx-1.16.1//SSL//server.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            proxy_pass https://yunweiriji.com/;
            index  index.html index.htm;
        }
    }
通过该配置,代理访问https://yunweiriji.com/,需要注意证书路径的写法,和正常windows路径的斜杠是相反的,并且是双斜杠。(windows环境下nginx https 反向代理 证书路径写法)

4.nginx https(ssl)反向代理配置(IPv6)

    server {
        listen       [::]:443 ssl;
        server_name  www.yunweiriji.com;

        ssl_certificate      D://nginx-1.16.1//SSL//server.pem;
        ssl_certificate_key  D://nginx-1.16.1//SSL//server.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            proxy_pass https://yunweiriji.com/;
            index  index.html index.htm;
        }
    }
注意ipv6环境下,监听端口的写法和ipv4环境有所不同。


nginx

版权所有
侵权必究

上一篇
vscode多行代码如何一次性左右移动
下一篇
windows和Linux下的nginx启动、停止和重启操作