麒麟系统,安装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;
        }
    }
相关推荐
杨凯凡3 小时前
Spring Boot SSE 上线后不实时、频繁断线?Nginx 缓冲、心跳与连接回收实战
spring boot·后端·nginx
csdn_aspnet5 小时前
在 Docker 容器中本地运行 SQL Server
运维·docker·容器·sqlserver
Csvn6 小时前
Nginx 缓存体系:三层 key、七态 X-Cache-Status 与锁/stale 策略
后端·nginx
Z21-X7 小时前
云原生运维学习笔记:Kubernetes Volume 与 Secret 实验
运维·笔记·学习·云原生·kubernetes
你住过的屋檐9 小时前
【SeaweedFS】Linux上搭建SeaweedFS文件存储服务完整教程
linux·运维·服务器
Decay__9 小时前
PostgreSQL 体系架构全解 —— 进程模型、共享内存、MVCC 与 WAL 预写日志深入
运维·数据库·sql·mysql·架构
分布式存储与RustFS10 小时前
桶里的文件想当目录使:用 ZeroFS 把 RustFS 挂成一棵 POSIX 树
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
老余说AI10 小时前
跨境电商、课程出海:六款多语言视频翻译工具选型指南
大数据·运维·人工智能
分布式存储与RustFS11 小时前
向量表别堆本地盘:用 LanceDB 把数据集建在 RustFS 上
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
无忧.芙桃1 天前
Linux系统编程(四):用户与权限管理
linux·运维·服务器