通用配置
nginx_http.conf(无删减)
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
nginx_location.conf(无删减)
proxy_redirect http://$host/ http://$http_host/;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
nginx_server.conf(无删减)
server_name yangxunyu.xyz; #填写绑定证书的域名
ssl_certificate /etc/nginx/https/1_yangxunyu.xyz_bundle.crt; # 指定证书的位置,绝对路径
ssl_certificate_key /etc/nginx/https/2_yangxunyu.xyz.key; # 绝对路径,同上
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
ssl_prefer_server_ciphers on;
https文件
腾讯云申请SSL证书,链接:
https://console.cloud.tencent.com/ssl,申请成功后就能获得这两个文件(crt和key)
配置文件
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/default.d/nginx_http.conf;
#博客系统 本地页面 h5页面
server {
listen *:80;
listen *:443 ssl;
client_max_body_size 1024m;
include /etc/nginx/default.d/nginx_server.conf;
#halo博客系统
location / {
proxy_pass http://127.0.0.1:8091/;
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
#本地页面
location /pc/ {
alias /data/h5project/web_index_html/;
break;
}
#h5页面
location /h5/ {
alias /data/h5project/2021_spring_festival_travel/;
break;
}
#有机蔬菜食品公司网站html源码
location /pc2/ {
alias /data/h5project/vegetables/;
break;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
执行niginx重启命令
nginx -s reload
再访问链接:
https://yangxunyu.xyz/pc2/ 。就能正常访问了。以上就是我服务nginx的配置文件,至于是否正确,是否合理,大家酌情参考,我只是分享下我的配置情况。nginx每项的含义,大家百度/Google了哦。
版权申明:本站文章均来自网络,如有侵权,请联系01056159998 邮箱:itboby@foxmail.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有