ご閲覧ありがとうございます。
今回は社内LANから外部に向けてWEBサーバーを公開することが目的です。
問題点
・現場は社内であり、ルーターのポートフォワーディングが利用できず、グローバルIPアドレスからのアクセスは不可
・Flask製のWEBアプリケーションを用いて、スレッド化するとエラーを起こす仕様になってしまっていること。
でございます。
解決策としては、
5個のサーバー(使用者数)をローカルに立ち上げ、ngrokというサービスを用いてPCを仮想的に外部に公開し、port80番にNginxやSquidを立てて、使用者のIDに応じてアクセスを振り分ける方法を思いつきました。
example.com/testuserでアクセスするとWEBアプリケーション1に接続され
example.com/productでアクセスするとWEBアプリケーション2に接続される。
といった具合です。
ところが、Nginxの設定ファイルを変更しても、Squidの設定ファイルを変更しても正常に振り分ける事ができず、悩んでおります。
Nginx
1user nginx; 2worker_processes auto; 3error_log /var/log/nginx/error.log; 4pid /run/nginx.pid; 5 6# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. 7include /usr/share/nginx/modules/*.conf; 8 9events { 10 worker_connections 1024; 11} 12 13http { 14 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 15 '$status $body_bytes_sent "$http_referer" ' 16 '"$http_user_agent" "$http_x_forwarded_for"'; 17 18 access_log /var/log/nginx/access.log main; 19 20 sendfile on; 21 tcp_nopush on; 22 tcp_nodelay on; 23 keepalive_timeout 65; 24 types_hash_max_size 2048; 25 26 include /etc/nginx/mime.types; 27 default_type application/octet-stream; 28 29 # Load modular configuration files from the /etc/nginx/conf.d directory. 30 # See http://nginx.org/en/docs/ngx_core_module.html#include 31 # for more information. 32 include /etc/nginx/conf.d/*.conf; 33 34 server{ 35 listen localhost:80; 36 server_name localhost:80; 37 38 location /abc/ { 39 proxy_pass http://localhost:3000; 40 } 41 42 location /def/ { 43 proxy_pass http://localhost:3001; 44 } 45 }
localhost/abcにアクセスされた場合はhttp://localhost:3000にアクセスし、localhost/defにアクセスされた場合はhttp://localhost:3001にアクセスすることを期待しているのですが、どうもうまくいきません。
Squid
1http_port localhost:80 http_port localhost:80 accel defaultsite=localhost:3000
squid.confにこちらを追記いたしました。
こちらは、localhostにアクセスされたら3000番に飛ばすことを期待しているのですが、こちらも上手く動きません。
どうかご回答をよろしくおねがいいたします。
回答2件
あなたの回答
tips
プレビュー