nginx配置相关应用服务

1、无ssl证书的conf文件

bash 复制代码
     server {
        listen 80;
        server_name test.domain.com;
        root html;
        index index.html index.htm;

        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:8080; //此处可不要,如果只是前端静态页面
        }
    }

2、有ssl证书

将下载的ssl证书4个文件全部放在nginx目录里面,如下图

nginx的conf配置文件如下

bash 复制代码
server {
	listen 80;
	listen 443 ssl;
	server_name test.domain.com;
	root /data/web/static_file_software_web_catalogue; #静态或前端项目的目录
	index index.html; #项目首页

	ssl_certificate /usr/nginx/nginx-1.20.1/cert/test/test.domain.com_bundle.pem; #pem文件
	ssl_certificate_key /usr/nginx/nginx-1.20.1/cert/test/test.domain.com.key; #ket文件

	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

	ssl_session_timeout 5m;
	ssl_prefer_server_ciphers on;

	location / {
		proxy_http_version 1.1;
		proxy_set_header Connection "";
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		#proxy_pass http://127.0.0.1:8080; #有后端请求可配置
		root /data/web/static_file_software_web_catalogue; #静态或前端项目的目录
		index index.html; #项目首页
	}
}

至此结束,希望你的项目完美运行!

有问题可以留言交流,希望可以帮助您!

相关推荐
特长腿特长2 小时前
centos、ubantu系列机的用户和用户组的结构是什么?具体怎么配置?用户组权限怎么使用?这篇文章持续更新,帮助你复习linux的基础知识
linux·运维·centos
zzzyyy5382 小时前
Linux环境变量
linux·运维·服务器
赛博云推-Twitter热门霸屏工具3 小时前
Twitter运营完整流程:从0到引流获客全流程拆解(2026)
运维·安全·自动化·媒体·twitter
CHHC18803 小时前
NetCore树莓派桌面应用程序
linux·运维·服务器
帮我吧智能服务平台4 小时前
装备制造智能制造升级:远程运维与智能服务如何保障产线OEE
运维·服务器·制造
w6100104664 小时前
cka-2026-cri-dockerd
运维·k8s·cka
卤炖阑尾炎5 小时前
PostgreSQL 日常运维全指南:从基础操作到备份恢复
运维·数据库·postgresql
handsomestWei6 小时前
Docker引擎API接入配置
运维·http·docker·容器·api
Tingjct6 小时前
Linux常用指令
linux·运维·服务器
daad7776 小时前
wifi_note
运维·服务器·数据库