nginx ssl配置详解_nginx实现内外网同时访问

nginx ssl配置详解_nginx实现内外网同时访问1、nginx.conf添加includeproxy.conf2、配置proxy.confserver{ listen80;listen443ssl; server_name域名1; indexindex.jspindex.htmlindex.htmlindex.shtml; ssl_certificate域名1.com.pem;#ssl证书路径 ssl_certificate_key域名1.com.key;.

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

1、nginx.conf 添加 include proxy.conf

nginx ssl配置详解_nginx实现内外网同时访问

2、配置proxy.conf

server {
	listen 80;
        listen 443 ssl;        
	server_name 域名1;
	
	ssl_certificate      域名1.com.pem; #ssl证书路径
	ssl_certificate_key  域名1.com.key; #ssl证书路径

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

	ssl_ciphers  HIGH:!aNULL:!MD5;
	ssl_prefer_server_ciphers  on;
	location / {
		root /usr/dist; //vue路径
		index index.html;
                add_header Access-Control-Allow-Origin *;
                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,Authorization';
 
                if ($request_method = 'OPTIONS') {
                        return 204;
                }

	}
}

server {
        listen 80;
        listen 443 ssl;
	server_name 域名2; 
	index index.jsp index.html index.html index.shtml;
        ssl_certificate      域名2.com.pem;
        ssl_certificate_key  域名2.com.key;

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

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
	location / {
		proxy_pass http://127.0.0.1:8002;
		#proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-Ip $remote_addr;
		proxy_set_header X-Forwarded-For $remote_addr;
                add_header Access-Control-Allow-Origin *;
    		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,Authorization';
 
    		if ($request_method = 'OPTIONS') {
        		return 204;
    		}
	}
}
...
1、非泛型域名,一个子域名要绑定一个SSL证书
2、需要多个子域名代理同一IP下的不同端口,只需按上面的操作,配置多个server即可。

3、浏览器访问:

      https://域名1 ======>http://127.0.0.1:8001

      https://域名2 ======>http://127.0.0.1:8002

 

4、proxy_pass代理转发

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass http://127.0.0.1:8001;
        }

        location /proxy/ {
            proxy_pass http://127.0.0.1:8002/;
        }
}

浏览器访问:

      http://127.0.0.1 ======>http://127.0.0.1:8001

      http://127.0.0.1/proxy/ ======>http://127.0.0.1:8002/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/186732.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • vispy 显示 kitti 点云数据

    vispy 显示 kitti 点云数据

    2020年11月8日
    299
  • 异步调用

    异步调用同步调用,即:程序按定义的顺序依次执行的过程,每一行代码执行过程必须等待上一行代码执行完毕后才执行。而异步调用指:程序在执行时,无需等待执行的返回值可继续执行后面的代码。回调。其主要是解决异步方法执行

    2022年7月4日
    26
  • Git clone 超级慢

    Git clone 超级慢使用命令:gitclone-br1.13.0https://github.com/tensorflow/models.git克隆GitHub上的一个仓库,但是速度超级慢,最高速度不超过30KB/s解决办法:使用国内镜像网站:github.com.cnpmjs.org,你访问这个网站和访问github.com没有任何区别,但是速度快很多,所以我们可以从这个镜像网站进行克隆仓库。原命令:gitclone-br1.13.0https://github.com/tensorfl

    2022年7月21日
    19
  • Window永久关闭默认共享

    windows默认共享你如果是在这里关闭的,开机之后默认共享文件夹又是打开的。管理工具—计算机管理—共享文件夹–共享下面介绍一种简单的永久关闭默认共享文件夹。1.找到window的开机自启动文件夹,注:这是所有用户登录都会开机自启动文件夹。C:\ProgramData\Microsoft\Windows\StartMenu\Programs\StartUp2.创建一个bat脚本,然后开机就能自动关闭默认共享文件夹。…

    2022年4月7日
    54
  • 图像识别与卷积神经网络

    图像识别与卷积神经网络卷积神经网络是除了全连接神经网络以外另一个常用的网络结果,其在图像识别方面表现十分突出。本文结合Tensorflow:实战Google深度学习框架,讲述卷积神经网络常用数据集,介绍卷积网络的结构思想,以及通过TensorFlow实现其设计。1图像识别数据集MNIST手写体识别数据集解决是一个相对简单的问题,而对于更加复杂的类别,可以用到CIFAR数据集。比如CIFAR10数据集收集了来自10…

    2022年5月30日
    45
  • vijos 1115 火星人

    vijos 1115 火星人

    2022年1月26日
    44

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号