正如标题所示,我试图在Docker 的桌面上运行nextcloud和OnlyOffice,并且我试图阻塞nginx来接受通过LAN的连接,这样我就可以从网络上的其他计算机连接到服务器,所有这些计算机都在运行Windows 10。
虽然我在网上读过很多类似的文章,但似乎没有一个有我的特别设置,我也不知道从这里该怎么做。
到目前为止,我已经成功地完成了What:
1-安装了windows社区版本的docker引擎。我正在使用Docker的默认容器。
2-在这里使用github页面上的说明安装了坞-onlyoffice-nextcloud:
https://github.com/ONLYOFFICE/docker-onlyoffice-nextcloud
3-我现在可以在http://localhost/计算机上访问host上的nextcloud,但是我没有运气从网络上的任何其他计算机连接到它。
<#>问题:
我无法弄清楚是什么原因阻止我在本地连接到服务器,但我猜想这与nginx服务器配置有关。
下面是用于此设置的配置文件和脚本,以供参考:
码头--复合液
version: '3'
services:
app:
container_name: app-server
image: nextcloud:fpm
stdin_open: true
tty: true
restart: always
expose:
- '80'
- '9000'
volumes:
- app_data:/var/www/html
onlyoffice-document-server:
container_name: onlyoffice-document-server
image: onlyoffice/documentserver:latest
stdin_open: true
tty: true
restart: always
expose:
- '80'
- '443'
volumes:
- document_data:/var/www/onlyoffice/Data
- document_log:/var/log/onlyoffice
nginx:
container_name: nginx-server
image: nginx
stdin_open: true
tty: true
restart: always
ports:
- 80:80
- 443:443
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- app_data:/var/www/html
volumes:
document_data:
document_log:
app_data:
mysql_data:nginx.conf
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream backend {
server app-server:9000;
}
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
map $http_host $this_host {
"" $host;
default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}
map $http_x_forwarded_host $the_host {
default $http_x_forwarded_host;
"" $this_host;
}
server {
listen 80;
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
root /var/www/html;
client_max_body_size 10G; # 0=unlimited - set max upload size
fastcgi_buffers 64 4K;
gzip off;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
rewrite ^/.well-known/carddav /remote.php/dav/ permanent;
rewrite ^/.well-known/caldav /remote.php/dav/ permanent;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location / {
rewrite ^/remote/(.*) /remote.php last;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ =404;
}
location ~* ^/ds-vpath/ {
rewrite /ds-vpath/(.*) /$1 break;
proxy_pass http://onlyoffice-document-server;
proxy_redirect off;
client_max_body_size 100m;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $the_host/ds-vpath;
proxy_set_header X-Forwarded-Proto $the_scheme;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS off;
fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
fastcgi_pass backend;
fastcgi_intercept_errors on;
}
# Adding the cache control header for js and css files
# Make sure it is BELOW the location ~ \.php(?:$|/) { block
location ~* \.(?:css|js)$ {
add_header Cache-Control "public, max-age=7200";
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
# Optional: Don't log access to assets
access_log off;
}
# Optional: Don't log access to other assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
access_log off;
}
}
}set_.set
set -x
docker exec -u www-data app-server php occ --no-warnings config:system:get trusted_domains >> trusted_domain.tmp
if ! grep -q "nginx-server" trusted_domain.tmp; then
TRUSTED_INDEX=$(cat trusted_domain.tmp | wc -l);
docker exec -u www-data app-server php occ --no-warnings config:system:set trusted_domains $TRUSTED_INDEX --value="nginx-server"
fi
rm trusted_domain.tmp
docker exec -u www-data app-server php occ --no-warnings app:install onlyoffice
docker exec -u www-data app-server php occ --no-warnings config:system:set onlyoffice DocumentServerUrl --value="/ds-vpath/"
docker exec -u www-data app-server php occ --no-warnings config:system:set onlyoffice DocumentServerInternalUrl --value="http://onlyoffice-document-server/"
docker exec -u www-data app-server php occ --no-warnings config:system:set onlyoffice StorageUrl --value="http://nginx-server/"```
[1]: https://github.com/ONLYOFFICE/docker-onlyoffice-nextcloud发布于 2019-11-07 06:26:42
如果问题在windows防火墙中,请尝试禁用它并测试连接是否有效。如果工作正常,请重新启动windows防火墙,然后您可以按照下面的说明进行操作:
单击“启动”并在您的主机上键入Windows防火墙。
2-点击具有高级安全性的Windows防火墙。
3-在窗口左侧找到<#>Inbound规则,然后右击它。
4-单击New规则.将出现一个新窗口。
5-在Rule类型选项卡上选择端口,然后单击Next。
6-在Protocol和端口选项卡下,在第一个选项中选择<>TCP,在第二个选项中选择Specific本地端口:,并在文本框中键入80。单击Next。
7-在<>Action选项卡下,选择Allow连接。
8-在配置文件选项卡下,选中所有框,然后单击Next。
9-在 name 选项卡下,给您的规则取一个名称,然后键入一个关于它是什么的小描述,这样您就可以记住创建它的原因了。单击完成。
此规则现在应该是活动的,您应该能够通过在同一网络上的另一台计算机上键入其IP地址来连接到您的服务器。
请注意,我对这一主题的了解还不够充分,而且我正在学习。我正在使用这个软件包来完成个人任务和学习,所以安全性对我来说不是什么大问题,我也不知道我的这个“解决方案”从专家的角度来看有多糟糕。
So请小心进行。
https://serverfault.com/questions/990826
复制相似问题