这里不允许使用nginx – map指令

weixin_38065217 2019-09-12 12:14:53
我是所有这些devops的新手,所以请光临我.我正在关注本教程https://medium.com/startup-founder-panel/deploying-a-meteor-app-with-nginx-from-scratch-1332b32e99a5当我做sudo nginx -t我明白了 nginx: [emerg] "map" directive is not allowed here in /etc/nginx/sites-enabled/app:2 nginx: configuration file /etc/nginx/nginx.conf test failed 这是app文件 # this section is needed to proxy web-socket connections map $http_upgrade $connection_upgrade { default upgrade; '' close; } # HTTP server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; location = /favicon.ico { root /home/USERNAME/portal/programs/web.browser/app; access_log off; } location ~* "^/[a-z0-9]{40}\.(css|js)$" { gzip_static on; root /home/USERNAME/portal/programs/web.browser; access_log off; } location ~ "^/packages" { root /home/USERNAME/portal/programs/web.browser; access_log off; } # pass requests to Meteor location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; #for websockets proxy_set_header Connection $connection_upgrade; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; } } 这是nginx.conf user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## include /etc/nginx/mime.types; gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml applicatio n/xml+rss text/javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #} include /etc/nginx/sites-enabled/*; 所以有什么问题?提前致谢!
...全文
813 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38066001 2019-09-12
  • 打赏
  • 举报
回复
尝试将此添加到http {}中的nginx.conf: user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { # this section is needed to proxy web-socket connections map $http_upgrade $connection_upgrade { default upgrade; '' close; } ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## include /etc/nginx/mime.types; gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml applicatio n/xml+rss text/javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #} include /etc/nginx/sites-enabled/*; 这不起作用的原因是,您没有在http块中添加地图模块.根据Nginx文档,地图模块只能在http上下文中使用.请参阅Nginx的文档: http://nginx.org/en/docs/http/ngx_http_map_module.html#map
内容简介: 本课程以通俗易懂的方式讲解Nginx技术,课程内容包括:1.Nginx简介、安装Nginx 2. 配置服务器 3.反向代理 4.负载均衡 5.动静分离为什么需要NginxNginx轻量级,采用 C 进行编写,同样的 web 服务,会占用更少的内存及资源抗并发,nginx 以 epoll and kqueue 作为开发模型,处理请求是异步非阻塞的,负载能力比 apache 高很多,而 apache 则是阻塞型的。在高并发下 nginx 能保持低资源低消耗高性能 ,而 apache 在 PHP 处理慢或者前端压力很大的情况下,很容易出现进程数飙升,从而拒绝服务的现象。nginx 处理静态文件好,静态处理性能比 apache 高三倍以上。nginx 的设计高度模块化,编写模块相对简单。nginx 配置简洁,正则配置让很多事情变得简单,而且改完配置能使用 -t 测试配置有没有问题,apache 配置复杂 ,重启的时候发现配置出错了,会很崩溃。nginx 作为负载均衡服务器,支持 7 层负载均衡。nginx 本身就是一个反向代理服务器,而且可以作为非常优秀的邮件代理服务器启动特别容易, 并且几乎可以做到 7*24 不间断运行,即使运行数个月也不需要重新启动,还能够不间断服务的情况下进行软件版本的升级。社区活跃,各种高性能模块出品迅速。课程大纲: 为了让大家快速系统了解Nginx知识全貌,我为你总结了「Nginx技术框架图」,帮你梳理学习重点,建议收藏!!

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧