首页 > 技术文章 > nginx.conf 配置 upstream 名不能有下划线!

whl-jx911 2020-12-26 17:50 原文

备份下,nginx.conf 配置:

注意点:upstream  名不能有下划线!!

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

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;

keepalive_timeout 65;

#gzip on;

upstream adminserverlist {
server ip:8099;
}

upstream minserverlist {
server ip:9090;
}

# include /etc/nginx/conf.d/*.conf;

client_max_body_size 10m;

server {
listen 80;
# listen 443 ssl;
server_name 域名;
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;
location / {
alias /data1/www/html/dist/ ;
index index.html index.htm;
try_files $uri $uri/ /index.html;
autoindex on;
}
}

server {
listen 80;
# listen 443 ssl;
server_name 域名;
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;

location / {
proxy_pass http://adminserverlist/car-admin/;
index index.html index.htm;
}
}

server {
listen 80;
# listen 443 ssl;
server_name 域名;
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;

location / {
proxy_pass http://minserverlist/car-service/;
index index.html index.htm;
}
}
}

推荐阅读