In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to build a HTTP server in WEB development. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
HTTP server
Because tomcat is slow to deal with static resources, the first thing that comes to mind is to put all static resources (JS,CSS,image,swf)
When it comes to separate servers, use a faster HTTP server. Nginx is chosen here. Nginx is lighter than apache.
Configuration is easier, and nginx is not only a high-performance HTTP server, but also a high-performance reverse proxy server.
At present, many large websites use nginx, Sina, NetEase, QQ and so on all use nginx, which shows that the stability and performance of nginx are still very good.
1. Nginx installation (linux)
Http://nginx.org/en/download.html download * stable version
Download the corresponding template according to the functions you need. Here are the following modules:
Openssl-0.9.8l,zlib-1.2.3,pcre-8.00
Compile and install nginx:
/ configure-- without-http_rewrite_module-- with-http_ssl_module-- with-openssl=../../lib/openssl-0.9.8l-- with-zlib=../../lib/zlib-1.2.3-- with-pcre=../../lib/pcre-8.00-- prefix=/usr/local/nginx make make install
2. Nginx handles the configuration of static resources
# start GZIP compression CSS and JS gzip on; # compression level 1-9. Default is 1. The higher the compression level, the greater the compression ratio, and of course, the longer the compression time, the longer the compression time. # Compression type gzip_types text/css application/x-javascript # define the service for static resource access, corresponding domain name: res.abc.com server {listen 80; server_name res.abc.com; # enable caching of files read by the server, open_file_cache max=200 inactive=2h; open_file_cache_valid 3h; open_file_cache_errors off; charset utf-8 # judge that if it is a picture or swf, the client caches for 5 days location ~ * ^. +. (ico | gif | bmp | jpg | jpeg | png | swf) ${root / usr/local/resource/; access_log off; index index.html index.htm; expires 5d;} # due to frequent JS,CSS changes, the client caches for 8 hours location ~ * ^. +. (js | css) ${root / usr/local/resource/; access_log off Index index.html index.htm; expires 8h;} # other static resources location / {root / usr/local/resource; access_log off; expires 8h;}}
3. Nginx reverse proxy settings
# reverse proxy service, binding domain name www.abc.com server {listen 80; server_name www.abc.com; charset utf-8 # BBS uses Discuz! # in order to improve performance, part of the http header information will not be forwarded to the background server. # use proxy_pass_header and proxy_set_header to forward the necessary http header information to the background server location ^ ~ / bbs/ {root html; access_log off; index index.php # forward the information of host. If host is not set, the domain name obtained by using request.getServerName () in the background is not www.abc.com, but 127.0.0.1 proxy_set_header Host $host; # because of Discuz! For security, you need to obtain client-side User-Agent to determine whether each POST data comes from the same browser as * requests, # if User-Agent,Discuz is not forwarded! If you submit the data, you will report the error of "your request is incorrect and cannot be submitted" proxy_pass_header User-Agent; proxy_pass http://127.0.0.1:8081;} # other requests are forwarded to tomcat location / {root html; access_log off; index index.jsp; proxy_pass http://127.0.0.1:8080;} error_page 500502 503504 / 50x.html Location = / 50x.html {root html;}}
For more information on nginx configuration, please see: http://wiki.nginx.org/
If you are prompted to install GCC not found, run the following command to install (apt-get install build-essential), debian only
The above is how to build a HTTP server in WEB development. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.