基本参数
start ./nginx 启动
./nginx -s reload 重启
./nginx -s reopen 重新打开日志文件命令
./nginx -t 检查配置文件是否出错
./nginx -s stop 快速停止
./nginx -s quit 完整有序 停止,并保存相关信息
./nginx -v 简单显示版本信息
./nginx -V 显示版本信息和配置参数信息
nginx.conf配置
https配置
server {
listen 8888 ssl http2; # 端口配置
listen [::]:8888 ssl http2;
server_name localhost; # 本机
ssl_certificate /etc/nginx/ssl/XXX.crt; # 证书crt位置
ssl_certificate_key /etc/nginx/ssl/XXX.key; # 证书key位置
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5; # 密码加密方式
ssl_prefer_server_ciphers on; # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
location / {
root /usr/share/nginx/dist; # 文件位置
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /redirect-resource/ { # 接口代理
proxy_set_header Host $http_host;
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_pass https://127.0.0.1:8887/;
}
}
http配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 10m;
server {
listen 8084; # 端口
listen [::]:8084;
server_name localhost;
location / {
root /usr/share/nginx/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /prod-api/{
proxy_set_header Host $http_host;
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_pass http://127.0.0.1:8081/;
}
}
}
网友评论