incubator-answer icon indicating copy to clipboard operation
incubator-answer copied to clipboard

When choosing to log in to access the site, uploaded photos will not be displayed due to insufficient permissions.

Open xingbaokeji opened this issue 1 year ago • 20 comments

When choosing to log in to access the site, uploaded photos will not be displayed due to insufficient permissions. When the user logs in normally, photos, videos, and attachments cannot be displayed image image

xingbaokeji avatar Dec 30 '24 06:12 xingbaokeji

Maybe the following two issues can help you. https://github.com/apache/incubator-answer/issues/502 https://github.com/apache/incubator-answer/issues/667

LinkinStars avatar Dec 30 '24 08:12 LinkinStars

Thank you very much for your help. I basically understand the reason now. My current setup is: deploying Answer on a local network with an internal IP, and then using DDNS to map this to a domain name. I access Answer officially through the domain name and port number. However, after logging in, the images cannot be displayed. Is there any good solution?

Chinese(I don't know which country you are from, so I'm sending it in both languages to avoid not understanding the content): 非常感谢你的帮助,基本我也明白了原因。我现在的模式是:局域网部署answer,ip是内网的,然后用DDNS把这个解析映射到域名上,通过域名+端口号的方式正式访问answer的。登录之后就是图片无法显示。有没有什么好的方法么

xingbaokeji avatar Dec 31 '24 02:12 xingbaokeji

@xingbaokeji Sorry, I took a look, and it seems that there isn't currently a suitable solution to handle this particular scenario. Perhaps in future versions, we could disable this security measure through a special environment variable or setting.

LinkinStars avatar Dec 31 '24 10:12 LinkinStars

ok,Thank you.。You can try to revoke the permission for the images in the issue, or make them selectable in the background for users to self manage risks. At present, users cannot see the specific content of the website without logging in, so I believe that revoking their image viewing permission is safe.

xingbaokeji avatar Jan 02 '25 00:01 xingbaokeji

If you are okay with your images being publicly available, I resolved this by NGIX proxy. Here is my config.

server {
    server_name answer.msa.com;

    # Serve static files directly
    location /uploads/ {
	# Use the symlink path to /var/lib/docker/volumes/root_answer-data/_data/uploads
        alias /var/www/uploads/; 
        autoindex off;
        allow all;
    }

    # Proxy all other requests to the application on port 9080
    location / {
        proxy_pass http://127.0.0.1:9080;
        proxy_set_header Host $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-Proto $scheme;
    }

    # SSL settings managed by Certbot
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/answer.msa.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/answer.msa.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

server {
    if ($host = answer.msa.com) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    server_name answer.msa.com;
    return 404;
}

nabekhan avatar Jan 12 '25 18:01 nabekhan

我也遇到了这个问题,修改了 登录--非公开--需要登录,按钮后,论坛里的图片都打不开了。请问我需要内网访问,不能映射到公网去,这个问题怎么解决

Image

vipelanchen avatar Aug 18 '25 09:08 vipelanchen

通过修改配置文件 或者 其他简单的方式可以解决这个问题吗?

vipelanchen avatar Aug 18 '25 09:08 vipelanchen

我是通过 docker 进行安装的,使用的mysql。并没有安装nginx等。

vipelanchen avatar Aug 18 '25 09:08 vipelanchen

通过修改配置文件 或者 其他简单的方式可以解决这个问题吗?

@vipelanchen If you know why this problem occurs and still want to skip the verification. You can try using the solution below. Set the SKIP_FILE_ACCESS_VERIFY environment variable to true in docker-compose.yaml.

LinkinStars avatar Aug 18 '25 09:08 LinkinStars

通过修改配置文件或者简单其他的方式可以解决这个问题吗?

@vipelanchen如果您知道此问题的原因,但仍想跳过验证。您可以尝试以下解决方案。SKIP_FILE_ACCESS_VERIFY在 docker-compose.yaml 中将环境变量设置为 true。

你好,我是用过docker run -d -p 9080:80 -v answer-data:/data --name answer apache/answer:latest 进行安装的,docker compose.yaml 文件在哪里修改

vipelanchen avatar Aug 18 '25 10:08 vipelanchen

通过修改配置文件或者简单其他的方式可以解决这个问题吗?

@vipelanchen如果您知道此问题的原因,但仍想跳过验证。您可以尝试以下解决方案。SKIP_FILE_ACCESS_VERIFY在 docker-compose.yaml 中将环境变量设置为 true。

你好,我是用过docker run -d -p 9080:80 -v answer-data:/data --name answer apache/answer:latest 进行安装的,docker compose.yaml 文件在哪里修改

@vipelanchen

docker run -d -p 9080:80 -v answer-data:/data -e SKIP_FILE_ACCESS_VERIFY=true --name answer apache/answer:latest

LinkinStars avatar Aug 18 '25 10:08 LinkinStars

@LinkinStars 非常感谢您的回答,太棒了,目前测试可用

vipelanchen avatar Aug 18 '25 10:08 vipelanchen

现在已经将内网端口映射到公网上,并做了域名解析,出现了一个问题? 账号设置--自定义头像--上传图片--确定后,页面就报错了

Image Image

@LinkinStars 老师可以提供一下帮助吗

vipelanchen avatar Sep 04 '25 08:09 vipelanchen

现在已经将内网端口映射到公网上,并做了域名解析,出现了一个问题? 账号设置--自定义头像--上传图片--确定后,页面就报错了

@LinkinStars 老师可以提供一下帮助吗

@vipelanchen Could you please provide the error logs when an error occurred? You can view the log using the docker logs command.

LinkinStars avatar Sep 04 '25 08:09 LinkinStars

log 好像看不出什么异常

Image

vipelanchen avatar Sep 04 '25 08:09 vipelanchen

用内网地址登录,例如192.168.. 登录是可以正常上传头像和保存,用公网域名就无法正常上传头像和保存

vipelanchen avatar Sep 04 '25 08:09 vipelanchen

@LinkinStars 这个是需要哪里配置一下吗?

vipelanchen avatar Sep 04 '25 08:09 vipelanchen

log 好像看不出什么异常

@vipelanchen According to the logs, this request may not have been received by the backend. You can check the requests via your browser's Inspect to see if the requests are working.

LinkinStars avatar Sep 04 '25 08:09 LinkinStars

@LinkinStars 好的,我先看下研究一下,非常感谢

vipelanchen avatar Sep 04 '25 09:09 vipelanchen

@LinkinStars 非常感谢您的支持,经过排查,是企业防火墙将写入信息拦截掉了,IP加白后,可以正常使用

vipelanchen avatar Sep 05 '25 03:09 vipelanchen