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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • ofbiz学习笔记

    ofbiz学习笔记

    2022年1月27日
    49
  • 决策树算法(C4.5)

    决策树算法(C4.5)

    2021年11月19日
    35
  • 2个list取交集_角的集合如何取交集

    2个list取交集_角的集合如何取交集两个List集合取交集、并集、差集、去重并集的一个简单Demo,可供参考:importjava.util.ArrayList;importjava.util.List;importstaticjava.util.stream.Collectors.toList;publicclassTest{publicstaticvoidmain(String[]args){List<String>list1=newArrayLi

    2022年10月6日
    0
  • Oracle之AUTHID CURRENT_USER

    Oracle之AUTHID CURRENT_USER

    2021年8月17日
    80
  • 究竟什么是可重入锁?

    究竟什么是可重入锁?经历很久之前就听说了可重入锁,可重入锁究竟是什么意思,以前是囫囵吞枣的,只要记住ReentrantLock和sychronized是可重入锁就行了,爱咋用咋用,好吧,原谅我的无知,最近对基础查漏补缺,发现竟然对其一问三不知,赶紧预习一波,觉得有必要写一篇博客来讲解,就当做什么都没有发生吧,嘿嘿。。。释义广义上的可重入锁指的是可重复可递归调用的锁,在外层使用锁之后,在内层仍然可以使用,并且不发生死锁(

    2022年6月26日
    21
  • mybatis中resultMap配置细则

    mybatis中resultMap配置细则resultMap算是mybatis映射器中最复杂的一个节点了,能够配置的属性较多,我们在mybatis映射器配置细则这篇博客中已经简单介绍过resultMap的配置了,当时我们介绍了resultMap中的id和result节点,那么在resultMap中除了这两个之外,还有其他节点,今天我们就来详细说说resultMap中的这些节点。如果小伙伴对mybatis尚不了解,建议先翻看博主前面几篇

    2022年10月27日
    0

发表回复

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

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