{"id":5647,"date":"2020-04-19T00:25:24","date_gmt":"2020-04-18T15:25:24","guid":{"rendered":"http:\/\/pecos.ddns.net\/wordpress\/?p=5647"},"modified":"2020-04-19T00:37:13","modified_gmt":"2020-04-18T15:37:13","slug":"asp-net-core-3-1-centos7-apache","status":"publish","type":"post","link":"https:\/\/pecos.ddns.net\/wordpress\/?p=5647","title":{"rendered":"asp.net core 3.1 + centos7 + apache"},"content":{"rendered":"<p>asp.net core 3.1\u3067\u622f\u308c\u308b<br \/>\ndotnet 3.1\u306b\u306a\u3063\u3066\u65e2\u5b58\u306e\u30bd\u30fc\u30b9\u3068\u304b\u3001\u307b\u307c\u305d\u306e\u307e\u307ecore\u3067\u3082\u30d3\u30eb\u30c9\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u6765\u305f\u3002\u3053\u308c\u307e\u3067MVC5\u3092\u4f7f\u3063\u3066\u6765\u305f\u306e\u3060\u304c\u3001\u3044\u3088\u3044\u3088\u5c06\u6765\u306e\u79fb\u884c\u3082\u8996\u91ce\u306basp.net core\u3092\u89e6\u3063\u3066\u307f\u308b\u3002<br \/>\nVisualStudio\u4e0a\u3067\u52d5\u304b\u3059\u306e\u306f\u7c21\u5358\u3060\u304c\u3001\u3044\u3056deploy\u3068\u306a\u308b\u3068\u3069\u3046\u306a\u3093\u3060\u308d\u3046\uff1f\u3068\u3044\u3046\u3053\u3068\u3067centos7\u4e0a\u3067kestrel\u3092apache\u3067\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u7d4c\u7531\u3067\u516c\u958b\u3059\u308b\u30c6\u30b9\u30c8\u3092\u3057\u3066\u307f\u305f\u3002vs\u3067\u30e9\u30f3\u30bf\u30a4\u30e0\u304b\u3089\u4f55\u304b\u3089\u4e00\u672c\u306edll\u306b\u307e\u3068\u3081\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u7d20\u6674\u3089\u3057\u3044\u30aa\u30d7\u30b7\u30e7\u30f3\u3067publish\u3057\u305f\u30d0\u30a4\u30ca\u30ea\u3092\u4f7f\u7528\u3002centos\u4e0a\u3067\u305d\u306edll\u3092\u666e\u901a\u306b\u52d5\u304b\u3059\u3060\u3051\u3067\u3001\u305d\u306e\u307e\u307ewebapp\u304c\u52d5\u304f\u306e\u3067\u304a\u6c17\u697d\u3060\u3002<br \/>\n\u65e2\u5b9a\u3067\u306fkestrel\u3092\u52d5\u304b\u3059\u3068&#8221;http:\/\/localhost:5000&#8243;\u3068\u3057\u3066\u52d5\u4f5c\u3059\u308b\u304c\u3001\u3053\u308c\u3092\u305d\u306e\u307e\u307eapache\u7d4c\u7531\u3067\u516c\u958b\u3059\u308b\u3068web\u306eroot&#8221;\/&#8221;\u306b\u306a\u3063\u3066\u3057\u307e\u3046(\u51e1\u4f8b&#8221;http:\/\/www.example.com\/&#8221;)\u3002<br \/>\n\u305d\u3053\u3067\u3001\u5916\u90e8\u304b\u3089\u306f&#8221;myapp&#8221;\u3068\u304b\u306e\u540d\u524d\u3067\u516c\u958b\u3057\u305f\u3044(\u51e1\u4f8b&#8221;http:\/\/www.example.com\/myapp&#8221;)\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u8a66\u884c\u932f\u8aa4\u3057\u305f\u7d50\u679c\u3092\u5099\u5fd8\u9332\u306b\u3057\u3066\u304a\u3053\u3046\u3002<br \/>\n\u307e\u305a\u306fasp.net core\u306e\u30a2\u30d7\u30ea\u5074\u306e\u7d30\u5de5\uff1a<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/1) kestrel\u3067&quot;myapp&quot;\u304cbasepath\u306b\u306a\u308b\u3088\u3046\u306b\u3059\u308b\r\npublic void Configure(IApplicationBuilder app, IWebHostEnvironment env) {\r\n        :\r\n    app.UsePathBase(&quot;myapp&quot;);\r\n    app.UseStaticFiles();\r\n        :\r\n    app.UseForwardedHeaders(new ForwardedHeadersOptions {\r\n        ForwardedHeaders = ForwardedHeaders.All\r\n    });\r\n        :\r\n}\r\n<\/pre>\n<p>\u6b21\u306bapache\u5074\u306e\u8a2d\u5b9a\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#2) apache\u306e\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u3092\u8a2d\u5b9a\r\n&lt;VirtualHost *:*&gt;\r\n        RequestHeader set &quot;X-Forwarded-Proto&quot; expr=%{REQUEST_SCHEME}e\r\n&lt;\/VirtualHost&gt;\r\n\r\n&lt;VirtualHost *:80&gt;\r\n        ProxyPreserveHost On\r\n        ProxyPass \/myapp http:\/\/localhost:5000\/myapp\r\n        ProxyPassReverse \/myapp http:\/\/localhost:5000\/myapp\r\n        ServerName www.example.com\r\n        &lt;Location \/myapp&gt;\r\n                Require all denied\r\n                Require ip 127.0.0.1\/32\r\n                Require ip 192.168.0.0\/24\r\n        &lt;\/Location&gt;\r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>\u3053\u308c\u3067\u53d6\u308a\u3042\u3048\u305a\u306f&#8221;myapp&#8221;\u3067\u516c\u958b\u3055\u308c\u305f\u3002<br \/>\n\u305d\u3057\u3066\u66f4\u306b\u3001\u30aa\u30ec\u30aa\u30ec\u8a3c\u660e\u66f8\u3067https\u306b\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u4e0a\u8a18\u306econf\u3092\u66f8\u304d\u63db\u3048\u305f\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#2') apache\u306e\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u3092\u8a2d\u5b9a(https)\r\n&lt;VirtualHost *:*&gt;\r\n        RequestHeader set &quot;X-Forwarded-Proto&quot; expr=%{REQUEST_SCHEME}e\r\n&lt;\/VirtualHost&gt;\r\n\r\n&lt;VirtualHost *:80&gt;\r\n        RewriteEngine On\r\n        RewriteCond %{REQUEST_URI} \/myapp\r\n        RewriteCond %{HTTPS} off\r\n        RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} &#x5B;R,L]\r\n\r\n        &lt;Location \/myapp&gt;\r\n                Require all denied\r\n                Require ip 127.0.0.1\/32\r\n                Require ip 192.168.0.0\/24\r\n        &lt;\/Location&gt;\r\n&lt;\/VirtualHost&gt;\r\n\r\n&lt;VirtualHost *:443&gt;\r\n        ProxyPreserveHost On\r\n        ProxyPass \/myapp http:\/\/localhost:5000\/myapp\r\n        ProxyPassReverse \/myapp http:\/\/localhost:5000\/myapp\r\n        SSLEngine on\r\n        SSLProtocol all -SSLv2\r\n        SSLCipherSuite ALL:!ADH:!EXPORT:SSLv2:!RC4+RSA:+HIGH:+MEDIUM:!LOW:!RC4\r\n        SSLCertificateFile \/etc\/pki\/tls\/certs\/localhost.crt\r\n        SSLCertificateKeyFile \/etc\/pki\/tls\/private\/localhost.key\r\n\r\n        &lt;Location \/myapp&gt;\r\n                Require all denied\r\n                Require ip 127.0.0.1\/32\r\n                Require ip 192.168.0.0\/24\r\n        &lt;\/Location&gt;\r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u306b\u306f\u6700\u521d\u306b\u6012\u3089\u308c\u308b\u304c\u3001\u69cb\u308f\u305a\u7d9a\u3051\u308b\u3068https\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u305f\u3002<br \/>\n\u3053\u308c\u306a\u3089\u3001kestrel\u306e\u30dd\u30fc\u30c8\u3092webapp\u6bce\u306b\u5909\u3048\u308c\u3070\u540c\u3058\u30b5\u30fc\u30d0\u3067\u8907\u6570\u516c\u958b\u51fa\u6765\u305d\u3046\u3060\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>asp.net core 3.1\u3067\u622f\u308c\u308b dotnet 3.1\u306b\u306a\u3063\u3066\u65e2\u5b58\u306e\u30bd\u30fc\u30b9\u3068\u304b\u3001\u307b\u307c\u305d\u306e\u307e\u307ecore\u3067\u3082\u30d3\u30eb\u30c9\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u6765\u305f\u3002\u3053\u308c\u307e\u3067MVC5\u3092\u4f7f\u3063\u3066\u6765\u305f\u306e\u3060\u304c\u3001\u3044\u3088\u3044\u3088\u5c06\u6765\u306e\u79fb\u884c\u3082\u8996\u91ce\u306basp.net  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,5],"tags":[],"class_list":["post-5647","post","type-post","status-publish","format-standard","hentry","category-asp","category-5"],"_links":{"self":[{"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/5647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5647"}],"version-history":[{"count":7,"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/5647\/revisions"}],"predecessor-version":[{"id":5654,"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/5647\/revisions\/5654"}],"wp:attachment":[{"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pecos.ddns.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}