nginxの簡単な紹介

Nginxとは

Nginxの説明NginxはWebサーバーとして使用できますが、ゲートウェイとして必要な機能を備えているため、ゲートウェイとして使用することがよくあります。

  • ディレクションエージェント
  • 負荷分散
  • 動的ルーティング
  • リクエストフィルタリング

サーバータイプ

Webサーバーは2つのカテゴリに分類されます。

  1. Webアプリケーションサーバー:
    • Tomcat
    • 樹脂
    • 桟橋
  2. Webサーバー
    • Apache
    • Nginx
    • IIS

区別:WebサーバーはJSPなどのページを解析できませんが、JS / CSS / htmlなどの静的リソースのみを処理できます。
並行性:Webサーバーの並行性機能は、Webアプリケーションサーバーの並行性機能よりもはるかに高くなっています。

Nginx方向プロキシ

ディレクションエージェンシーとは何ですか?
  • プロキシ:クライアントの構成を通じて、サーバーはクライアントのプロキシとして機能でき、クライアントからのすべての要求は処理のためにプロキシサーバーに渡されます。
  • リバースプロキシ:サーバーを使用して実サーバーをプロキシします。ユーザーがアクセスすると、実サーバーにはアクセスされなくなり、プロキシサーバーにアクセスされます。

Nginxは方向プロキシサーバーとして使用できます。

  • 事前にnginxでリバースプロキシルールを設定する必要があり、処理のためにさまざまなリクエストがさまざまな実サーバーに渡されます
  • リクエストがnginxに到着すると、nginxは定義されたルールに従ってリクエストを転送し、ルーティング機能を実現します

nginxディレクトリ構造
nginxディレクトリ構造図1.conf:構成ディレクトリ
2. contrib:サードパーティの依存関係
3. html:tomcatのwebappsと同様のデフォルトの静的リソースディレクトリ
4.ログ:ログディレクトリ
5. nginx.exe:起動プログラム。ダブルクリックして実行できますが、これはお勧めしません。

#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  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;
	server{
		listen 80;
		server_name manage.ishop.com;
		
		proxy_set_header X-Forworded-Host $host;
		proxy_set_header X-Forworded-Server $host;
		proxy_set_header X-Forworded-For $proxy_add_x_forwarded_for;
		
		location / {
			proxy_pass http://127.0.0.1:9001;
			proxy_connect_timeout 600;
			proxy_read_timeout 600;
		}
	}
	server{
		listen 80;
		server_name api.ishop.com;
		
		proxy_set_header X-Forworded-Host $host;
		proxy_set_header X-Forworded-Server $host;
		proxy_set_header X-Forworded-For $proxy_add_x_forwarded_for;
		
		location / {
			proxy_pass http://127.0.0.1:9002;
			proxy_connect_timeout 600;
			proxy_read_timeout 600;
		}
	}
   #server {
   #       listen       80;
   #	server_name localhost;

   #     #charset koi8-r;

   #     #access_log  logs/host.access.log  main;

   #    location / {
   #        root   html;//定义网站根目录,目录可以是相对路径也可以是绝对路径。
   #        index  index.html index.htm;//定义站点的默认页。
   #    }

   #     #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;//定义50x.html所在路径
   #     }

   #   # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
   #    #location ~ \.php$ {
   #    #    proxy_pass   http://127.0.0.1;
   #    #}

   #   # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
   #   #
   #   #location ~ \.php$ {
   #   #    root           html;
   #    #    fastcgi_pass   127.0.0.1:9000;
   #    #    fastcgi_index  index.php;
   #    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
   #   #    include        fastcgi_params;
   #    #}

   #    # deny access to .htaccess files, if Apache's document root
   #    # concurs with nginx's one
   #   #
   #    #location ~ /\.ht {
   #    #    deny  all;
   #    #}
   # }


    # 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;
    #    }
    #}
}

ここに画像の説明を挿入
nginxコマンド
startnginx start nginx.exe
restart nginx -s reload
stop nginx -s stop

SwitchHosts-win32-x64_v3.3.11.5347

SwitchHostsは、複数のホストスキームを変更、管理、および切り替えるためのオープンソースツールです。
ここに画像の説明を挿入ここに画像の説明を挿入SwitchHostsには、さまざまなホスト設定をすばやく切り替えてホストファイルを編集するのに役立つだけでなく、次のような非常に優れた機能もあります。

免费、开源、支持三大操作系统
系统托盘快速「一键切换」不同的 hosts 方案
支持 hosts 文件语法高亮,可以方便用户更直观地阅读和修改 Hosts 内容;
编辑 hosts 时,可以点击行号可以对行进行快速注释或取消注释
支持远程 hosts,直接从指定网址读取 hosts 内容,方便多台机器同步 hosts 设置,这是一个很赞的特性!
支持 hosts 配置的导入、导出备份
macOS 系统下可以支持 Alfred workflow 快速切换

基本的に、SwitchHostsを使用すると、ホストでやりたいことが何でもでき、ワンクリックで簡単に切り替えることができます。さらに、リモートhsotsソリューションは、コンピューターを頻繁に変更してどこでも使用する人にとっても非常に便利です。これもそのハイライトです

ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/weixin_42789301/article/details/105406042