我的团队有一个用于内部工具和测试的服务器。它有一个指向它的子域:myserver.mycompany.com。我们试图实现的是拥有多个应用程序,每个应用程序都在一个子目录下。即:
myserver.mycompany.com -泛型条目页myserver.mycompany.com/redmine我们的内部红宝石( rails服务器上的红宝石)myserver.mycompany.com/opensocial,我们目前正在测试的一个drupal网站(一个php应用程序)我设法让redmine在子目录下工作,而不是在子目录上的drupal网站上工作。
有什么建议吗?
下面是我的默认vhost的简化版本:
server {
# server name and ssl stuff
root /var/www/html;
## REDMINE
location ~ ^/redmine(/.*|$) {
alias /opt/redmine/public$1;
passenger_base_uri /redmine;
passenger_app_root /opt/redmine;
passenger_document_root /opt/redmine/public;
passenger_enabled on;
}
## END REDMINE
## START Open Social
location ~ ^/opensocial(/.*|$) {
alias /var/www/opensocial/html$1;
index index.php;
location ~ ^/opensocial(/.*|$) {
try_files $uri /index.php?$query_string; # For Drupal >= 7
}
# From nginx's drupal config
location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
# Ensure the php file exists. Mitigates CVE-2019-11043
try_files $fastcgi_script_name =404;
# Security note: If you're running a version of PHP older than the
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
# See http://serverfault.com/q/627903/94922 for details.
include fastcgi_params;
# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
# PHP 7 socket location.
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
## END OF Open Social谢谢
发布于 2022-11-02 14:23:37
这主要是评论(但注释框中的空间有限)
我设法让redmine在子目录下工作,但没有在drupal网站上工作。
当您尝试访问drupal时,What发生在浏览器上?你的日志上写了什么?
location ~ ^/opensocial(/.*|$) {
alias /var/www/opensocial/html$1;这太可怕了。我猜您真的很想独立地管理这两个应用程序的路径。有什么很好的理由让你不用
location /opensocial {?
当您使用类似的模式来处理红矿时,您确实在不同的位置安装了它。我并不熟悉乘客是如何工作的,但我认为passenger_base_uri会使正则表达式和别名变得多余。
就我个人而言,我会使用3个单独的服务器{}实例,并在端口80 & 443上放置一个代理--额外跳的开销可以忽略不计,并且有扩展、安全和管理的好处。
发布于 2022-11-04 11:03:13
基于@symcbean答案,我为每个应用程序创建了一个代理服务器。
我现在的问题是来自drupal网站的内部链接和资源上的404,但我想这是一个应用程序问题。
这是我的新主持人:
server {
# server name and ssl stuff
root /var/www/html;
location /redmine {
proxy_pass http://127.0.0.1:8000;
}
location /opensocial {
proxy_pass http://127.0.0.1:8001;
}
}
## REDMINE
server {
listen 127.0.0.1:8000;
root /opt/redmine/public;
passenger_base_uri /redmine;
passenger_app_root /opt/redmine;
passenger_document_root /opt/redmine/public;
passenger_enabled on;
}
## OPEN SOCIAL
server {
listen 127.0.0.1:8001;
root /var/www/opensocial/html;
location / {
try_files $uri /index.php?$query_string;
}
location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
# Ensure the php file exists. Mitigates CVE-2019-11043
try_files $fastcgi_script_name =404;
# Security note: If you're running a version of PHP older than the
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
# See http://serverfault.com/q/627903/94922 for details.
include fastcgi_params;
# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
# PHP 7 socket location.
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}如果你有什么我能做得更好的事,请评论。
https://serverfault.com/questions/1114613
复制相似问题