{"id":8983,"date":"2019-12-31T10:37:24","date_gmt":"2019-12-31T01:37:24","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=8983"},"modified":"2023-05-27T21:37:10","modified_gmt":"2023-05-27T12:37:10","slug":"%e3%80%90nginx%e3%80%91%e5%9f%ba%e6%9c%ac","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=8983","title":{"rendered":"\u3010nginx\u3011\u8a2d\u5b9a\u306e\u57fa\u672c\u3001\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u306e\u8a2d\u5b9a"},"content":{"rendered":"<h2>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240<\/h2>\n<pre class=\"lang:default decode:true\">\/etc\/nginx\/conf.d\/default.conf<\/pre>\n<div>\n<h2>upstream\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6<\/h2>\n<p>\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u30b5\u30fc\u30d0\u30fc\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u30b5\u30fc\u30d0\u3068\u306f\u4e0a\u4f4d\u30b5\u30fc\u30d0\u30fc\uff08\u8ee2\u9001\u5148\u30b5\u30fc\u30d0\uff09\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<div>\n<pre class=\"lang:default decode:true\">upstream \u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u540d {\r\n  server \u30a2\u30c9\u30ec\u30b9\r\n}<\/pre>\n<h3>server\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6<\/h3>\n<p>weight\u30d1\u30e9\u30e1\u30fc\u30bf\u306a\u3069\u3067\u305d\u308c\u305e\u308c\u306e\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u306e\u91cd\u307f\u4ed8\u3051\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30c9\u30ec\u30b9\u306b\u306fsock\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3059\u308b\u306a\u3069\u3057\u3066\u30bd\u30b1\u30c3\u30c8\u901a\u4fe1\u3055\u305b\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<\/div>\n<\/div>\n<h2>sever\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6<\/h2>\n<p>\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u3054\u3068\u306b\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3067\u304d\u308b\u3002<\/p>\n<h3>listen<\/h3>\n<p>\u30ea\u30c3\u30b9\u30f3\u3057\u3066\u3044\u308b\uff08\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u308b\uff09\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u793a\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f80\u756a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>server_name<\/h3>\n<p>\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u306e\u540d\u524d<\/p>\n<h3>root<\/h3>\n<p>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8<\/p>\n<h3>location<\/h3>\n<p>URL\u3068\u5b9f\u969b\u306e\u683c\u7d0d\u5148\u306e\u30d1\u30b9\u3092\u7d10\u4ed8\u3051\u308b\u3002<\/p>\n<h3>try_files<\/h3>\n<p>\u5de6\u304b\u3089\u9806\u306b\u5b9f\u4f53\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3001\u3042\u308c\u3070\u305d\u306e\u307e\u307e\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<div>\n<h3>location<\/h3>\n<p>\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u3001URL\u3092\u6307\u5b9a\u3057\u3066\u3069\u3053\u306b\u98db\u3070\u3059\u304b\u306a\u3069\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">location \u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9 URI\u306e\u30d1\u30b9 {\r\n    [location\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8]\r\n}<\/pre>\n<h4>\u540d\u524d\u4ed8\u304d\u30ed\u30b1\u30fc\u30b7\u30e7\u30f3<\/h4>\n<p>\u5177\u4f53\u7684\u306aURL\u306b\u306f\u95a2\u4e0e\u305b\u305a\u306b\u3001\u5185\u90e8\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u304c\u3057\u305f\u3044\u5834\u5408\u306b\u5229\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<div>\n<pre class=\"lang:default decode:true \">location @\u540d\u524d {\r\n    [location\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8]\r\n}<\/pre>\n<p><span style=\"font-size: 28px; font-weight: 900;\">\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u306e\u8a2d\u5b9a<\/span><\/p>\n<\/div>\n<\/div>\n<h3>\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u3068\u306f\uff1f<\/h3>\n<p>\u30e6\u30fc\u30b6\u30fc\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u53d6\u308a\u305d\u308c\u3092\u4e0a\u4f4d\u30b5\u30fc\u30d0\uff08\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u30b5\u30fc\u30d0\uff09\u306b\u8ee2\u9001\u3059\u308b\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<h3>\u4f8b\uff1aRails\u306epuma\u306b\u8ee2\u9001\u3059\u308b\uff08UNIX\u30bd\u30b1\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3044\u308b\u3002\uff09<\/h3>\n<pre class=\"lang:default decode:true\">upstream myapp {\r\n  server unix:\/\/\/myapp\/tmp\/sockets\/puma.sock;\r\n}\r\n\r\nserver {\r\n  try_files  $uri\/index.html $uri @myapp;\r\n\r\n  # \u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u95a2\u9023\u306e\u8a2d\u5b9a\r\n  location @myapp {\r\n    proxy_set_header X-Real-IP $remote_addr;\r\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n    proxy_set_header Host $http_host;\r\n    # upstream\u3067\u6307\u5b9a\u3057\u305f\u300cmyapp\u300d\r\n    proxy_pass http:\/\/myapp;\r\n  }\r\n}<\/pre>\n<h4>proxy_pass \u8ee2\u9001\u5148URI<\/h4>\n<p>\u30d7\u30ed\u30ad\u30b7\u5148\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30de\u30c3\u30c1\u3057\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u30b5\u30fc\u30d0\u306b\u30d7\u30ed\u30ad\u30b7\u3057\u307e\u3059\u3002<\/p>\n<h5>UNIX\u30bd\u30b1\u30c3\u30c8\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002<\/h5>\n<p>\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u5148\u3068\u3057\u3066UNIX\u30bd\u30b1\u30c3\u30c8\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\u5c55\u958b\u3055\u308c\u305f\u5f8c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true  \">http:\/\/unix:\/\/\/myapp\/tmp\/sockets\/puma.sock;<\/pre>\n","protected":false},"excerpt":{"rendered":"\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240 \/etc\/nginx\/conf.d\/default.conf upstream\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6 \u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u30b5\u30fc\u30d0\u30fc\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30a2\u30c3\u30d7\u30b9\u30c8\u30ea\u30fc\u30e0\u30b5\u30fc\u30d0\u3068\u306f\u4e0a\u4f4d\u30b5\u30fc\u30d0\u30fc\uff08\u8ee2\u9001\u5148\u30b5\u30fc\u30d0\uff09\u306e\u3053 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[91],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8983"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8983"}],"version-history":[{"count":11,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8983\/revisions"}],"predecessor-version":[{"id":20375,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8983\/revisions\/20375"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8983"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}