ApacheからNginxへの移行組です。
様々なページを参考にconfの設定をしhttpsを使ったHPの公開には成功しています。
▶問題点
・必要or追加が必要な構文の選定ができない
.htaccessが使えないため解説ページを参考にconfを設定しているのですが、追加で入力が必要となる構文の選定ができず設定ができません。
▶参考サイト①
https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx
server { # [...] # Location for wiki's entry points location ~ ^/w/(index|load|api|thumb|opensearch_desc).php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/w/$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on } # Images location /w/images { # Separate location for images/ so .php execution won't apply } location /w/images/deleted { # Deny access to deleted images folder deny all; } # MediaWiki assets (usually images) location ~ ^/w/resources/(assets|lib|src) { try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Assets, scripts and styles from skins and extensions location ~ ^/w/(skins|extensions)/.+.(css|js|gif|jpg|jpeg|png|svg)$ try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Favicon location = /favicon.ico { alias /w/images/6/64/Favicon.ico; add_header Cache-Control "public"; expires 7d; } ## Uncomment the following code if you wish to use the installer/updater ## installer/updater #location /w/mw-config/ { # # Do this inside of a location so it can be negated # location ~ .php$ { # include /etc/nginx/fastcgi_params; # fastcgi_param SCRIPT_FILENAME $document_root/w/mw-config/$fastcgi_script_name; # fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on # } #} # Handling for the article path (pretty URLs) location /wiki/ { rewrite ^/wiki/(?<pagename>.*)$ /w/index.php; include /etc/nginx/fastcgi_params; # article path should always be passed to index.php fastcgi_param SCRIPT_FILENAME $document_root/w/index.php; fastcgi_param PATH_INFO $pagename; fastcgi_param QUERY_STRING $query_string; fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on } # Allow robots.txt in case you have one location = /robots.txt { } # Explicit access to the root website, redirect to main page (adapt as needed) location = / { return 301 https://www.example.com/wiki/Main_Page; } # Every other entry point will be disallowed. # Add specific rules for other entry points/images as needed above this location / { return 404; } }
▶参考サイト②
https://www.mediawiki.org/wiki/Manual:Short_URL/Page_title_-_nginx,_Root_Access,_PHP_as_a_CGI_module
server { server_name www.example.com example.com; listen 80; root /home/user/public_html; index index.php index.html index.htm; access_log /var/log/nginx/access-example.log; error_log /var/log/nginx/error-example.log; location ~ .ht { deny all; } location / { try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/(.*)$ /index.php; } location ^~ /maintenance/ { return 403; } location ~ .php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; try_files $uri @rewrite; } }
▶現状
・nginx version: nginx/1.17.1(Centos7)
・var/www/html/test
・test.com
server { listen 80; server_name test.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443 ssl; server_name test.com; access_log /var/log/nginx/test.com-access.log main; error_log /var/log/nginx/test.com-error.log; root /var/www/html/test; ssl_certificate /etc/letsencrypt/live/test.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/test.com/privkey.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_session_tickets on; ssl_dhparam /etc/nginx/ssl/dhparam.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { index index.php index.html index.htm; } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
現状のConfと参考サイトのConfをどう組み合わせたらいいのかわかりません。
非常に申し訳ないのですが、ご享受頂けたら幸いです。
回答1件
あなたの回答
tips
プレビュー