nginx 安装配置(windows)
发布于: 2020 年 07 月 28 日
下载windows安装文件
http://nginx.org/en/download.html
正式环境最好下载stable 版本
配置config
conf/nginx.conf
#user nobody;worker_processes 2;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; gzip_min_length 1; server { listen 9091; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { alias html/admin/; index index.html index.htm; try_files $uri $uri/ @rewrites; } location @rewrites { rewrite ^(.+)$ /index.html last; } location /static/ { alias html/admin/static/; index index.html index.htm; } location /v1 { 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:8082; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 9092; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { alias html/web/; index index.html index.htm; try_files $uri $uri/ @rewrites; } location @rewrites { rewrite ^(.+)$ /index.html last; } location /static/ { alias html/web/static/; } location /v1 { 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:8082; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 443 ssl; #listen 443; server_name api.yhzy.org.cn; #charset koi8-r; #access_log logs/host.access.log main; ssl_certificate cert/4275674_api.yhzy.org.cn.pem; ssl_certificate_key cert/4275674_api.yhzy.org.cn.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location /v1 { 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:8082; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
页面相关配置
server { listen 9080; server_name localhost; location /admin { alias html/admin; index index.html index.htm; } }
接口相关配置
upstream api_server { server 127.0.0.1:8082; } # another virtual host using mix of IP-, name-, and port-based configuration # server { listen 443 ssl; listen 8082; server_name somename; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; location /api { 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://api_server } }
启动
到 nginx.exe 所在目录
start nginx.exe
重新加载
nginx.exe -s reload
划线
评论
复制
发布于: 2020 年 07 月 28 日阅读数: 79
陈靓-哲露
关注
还未添加个人签名 2018.04.12 加入
还未添加个人简介
评论