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)
上一篇 2022年10月2日 下午3:00
下一篇 2022年10月2日 下午3:16


相关推荐

  • VMware——VMware Tools的介绍及安装方法

    VMware——VMware Tools的介绍及安装方法VMware——VMwareTools的介绍及安装方法一、VMwareTools的作用二、VMwareTools的安装步骤参考文章一、VMwareTools的作用1.最大的好处是可以直接把windows界面的文件拖进linux虚拟机内。2.鼠标可以直接从虚拟机移动到windows等等好处。二、VMwareTools的安装步骤首先把linux虚拟机关机或退出,然后点击“编辑虚拟机设置”。点击CD/DVD,选择使用物理驱动器–自动检测。运行虚拟机虚拟机-安装vm

    2022年5月10日
    56
  • lwip udp 发送_lwip udp发送

    lwip udp 发送_lwip udp发送一、udp.c实现的函数1、void udp_input(structpbuf*p,structnetif*inp)说明:处理接收到的udp数据包。参数:p数据包缓存区;inp网络接口。   2、err_t udp_send(structudp_pc…

    2025年10月6日
    6
  • 2025年ChatGPT图像API全指南:GPT-4o与DALL-E图像生成集成教程

    2025年ChatGPT图像API全指南:GPT-4o与DALL-E图像生成集成教程

    2026年3月16日
    2
  • python 免费空间_总算找到php免费空间

    python 免费空间_总算找到php免费空间所谓免费免费空间 就是指主机运营商免费提供的网络空间 在网络服务器上划分出一定的磁盘空间供用户放置站点 应用组件等 以下就是小编给大家整理的 php 免费空间的使用方法 如何申请免费 PHP 空间方法一 1 请填写真实内容 邮箱需要激活验证才能开通空间 2 免费空间申请成功后 您的邮箱会收到一封邮件 里面有相关的空间和数据库信息 请注意查收 不看此邮件会影响到您的程序安装 注册成功点击控制台按钮 然后绑定

    2026年3月26日
    2
  • php 正则获取邮箱,PHP 邮箱正则表达式[通俗易懂]

    php 正则获取邮箱,PHP 邮箱正则表达式[通俗易懂]PHP邮箱正则表达式作者:PHPYuan时间:2018-07-0900:01:10PHP邮箱正则表达式代码如下:/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,})$/实例$mail=’runoob@runoob.com’;//邮箱地址$pattern=”/^[_a-z0-9-]+(.[_a-z0-9-…

    2022年6月17日
    30
  • 实现一维卷积神经网络的方法_卷积神经网络处理一维数据

    实现一维卷积神经网络的方法_卷积神经网络处理一维数据实现一维卷积神经网络1、准备IMDB数据fromkeras.datasetsimportimdbfromkeras.preprocessingimportsequencemax_features=10000max_len=500print(‘loadingdata……’)(x_train,y_train),(x_test,y_test)=imdb.load_data(num_words=max_feature)print(len(x_train),’trainse

    2026年2月15日
    5

发表回复

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

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