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; #项目首页
}
}
至此结束,希望你的项目完美运行!
有问题可以留言交流,希望可以帮助您!