麒麟系统,安装Nginx并配置https证书

powershell 复制代码
	cd /home/admin/

解压文件到opt目录下

powershell 复制代码
	tar -xvzf nginx-1.22.1.tar.gz -C /data/usr/local

	cd /data/usr/local/nginx-1.22.1

需要ssl的话用这个

powershell 复制代码
	./configure --prefix=/data/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

	./configure --prefix=/data/usr/local/nginx --with-http_ssl_module

	./configure --prefix=/data/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module

	make

	make install

Nginx配置证书

进入配置目录

powershell 复制代码
	cd /data/usr/local/nginx/conf/

创建cert目录

powershell 复制代码
	mkdir cert

将证书crt和key复制过来

powershell 复制代码
	cp /home/admin/xxx.crt /data/usr/local/nginx/conf/cert
	cp /home/admin/xxx.key /data/usr/local/nginx/conf/cert

修改配置文件

powershell 复制代码
		##another virtual host using mix of IP-, name-, and port-based configuration
		#
     server {
			listen       80;
			#    listen       somename:8080;
			server_name  **ip地址**;
			
			#    location / {
			#        root   html;
			#        index  index.html index.htm;
			#    }
			return 301 https://$http_host$request_uri;
     }


    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  **ip地址**;

        ssl_certificate      /data/usr/local/nginx/conf/cert/xxx.crt;
        ssl_certificate_key  /data/usr/local/nginx/conf/cert/xxx.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
			 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
			 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;

        location / {
            root   /data/vue;
					index index.html;
            try_files $uri $uri/ /index.html;			
        }
		
			location  ^~/api {
            proxy_set_header X-Forwarded-Proto $scheme;
					proxy_set_header X-Forwarded-Port $server_port;
					proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
					proxy_set_header Upgrade $http_upgrade;
					proxy_set_header Connection "upgrade";
            proxy_pass http://ip地址:8081;
        }
    }
相关推荐
月落汀兰1 小时前
拒绝配置写死镜像!K8s 存储卷与配置管理,PV/PVC、ConfigMap、Secret 实战避坑指南
运维·kubernetes
服务器硬件项目经理1 小时前
《超节点修仙录》· 第一卷·炼气期【第04话】 超节点 vs 普通服务器——不就是多插了几张卡吗?
运维·服务器·人工智能·嵌入式硬件·深度学习·机器学习
杨云龙UP2 小时前
MySQL 主从复制管理:暂停、恢复、清理主从关系及命令执行位置
运维·数据库·mysql·主从配置·主从命令·reset replica·清除复制
一直在努力学习的菜鸟2 小时前
阿里云SSL证书到期更换指南(Nginx + Typecho)
nginx
Android系统攻城狮2 小时前
Linux FFmpeg深度解析之avcodec_parameters_from_context调用流程与实战(十六)
linux·运维·ffmpeg·音视频进阶·ffmpeg音视频·车载音视频进阶
隔窗听雨眠2 小时前
从存储引擎到执行计划:OceanBase高效运维的调优逻辑与工程实践
运维·oceanbase
运维行者_2 小时前
供应链安全成最大风险源,企业如何构建可控的运维体系?
运维·开发语言·网络·数据库·安全·云计算·流量监控
xiaoyunxuexibiji3 小时前
采购协同管理:从备货计划、进度确认到到货签收
大数据·运维·人工智能
画中有画3 小时前
在自动化脚本中调用其他脚本文件
运维·自动化