win上配置nginx

Posted DonaHero

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了win上配置nginx相关的知识,希望对你有一定的参考价值。

win上配置nginx

    网上配置nginx的教程大多都是linux上的,今天贴出来nginx在win上的配置,在此篇配置中,nginx代理了Tomcat以及node服务。配置如下:

     注意:根据实际经验来看,在win上修改完成nginx之后,需要将nginx的所有服务都关闭,然后重启,否则,只是一味的reload则服务并不会生效。

#user nobody;
worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 96; #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;
  #node服务端口 upstream baidu.xxx.com{ server 127.0.0.1:9919; }
  #tomcat服务端口 upstream xinlang.xxx.com{ server 127.0.0.1:8080; } server { listen 80; server_name baidu.xxx.com ; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://127.0.0.1:9919; } } server { listen 80; server_name xianlang.xxx.com ; #charset koi8-r; #access_log logs/host.access.log main; location / { index index.html index.jsp; proxy_pass http://xinlang.xxx.com ; proxy_set_header X-Real-IP $remote_addr; client_max_body_size 100m; } } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # 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 / { # root html; # index index.html index.htm; # } #} }



以上是关于win上配置nginx的主要内容,如果未能解决你的问题,请参考以下文章

如何正确配置Nginx + PHP

nginx.conf 忽略了 nginx-ingress 配置映射片段

linux学习:Nginx--常见功能配置片段与优化-06

Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段

如何在Windows上配置并运行Nginx

如何在Windows上配置并运行Nginx