iT邦幫忙

0

請教Linux 環境內Apache使用Nas Server分享目錄作為虛擬目錄

我這一台主機上已經掛載 Synology RS815RP+ 的分享空間為這一台主機的/home6磁區
mount -t cifs //192.168.3.7/www -o username=xdrivex,password=adsp7er /home6/
我於httpd.conf內設定

Alias /upload "/home6/report"
<Directory "/home6/report">
Options MultiViews FollowSymLinks
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all

而/home6/report目錄內已經有資料夾
[root@HP home6]# ll /home6/report/
total 0
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2003
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2004
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2005
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2006
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2007
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2008
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2009
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2010
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2011
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2012
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2013
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2014
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2015
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2016
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2017
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2018
drwxrwxrwx. 2 1027 users 0 Feb 26 2020 2019

當我於網址輸入
http://xxx.xxx.xxx.tw/upload/2019/20192.pdf

然後出現

Forbidden

You don't have permission to access /upload/2019/20192.pdf on this server.
Apache/2.2.15 (CentOS) Server at xxx.xxx.xxx.tw Port 80

請問我還需要修改哪個設定呢? 謝謝!

看更多先前的討論...收起先前的討論...
froce iT邦大師 1 級 ‧ 2020-02-26 14:56:44 檢舉
sudo chmod -R 777 /home6/report/

777我亂給的,請去搞懂linux的權限。
jiannrong iT邦新手 5 級 ‧ 2020-02-26 15:54:15 檢舉
這台機器還有本機端的磁碟陣列,我設定為/home1 ,目錄也設定為777 也是同樣的問題,主要是原本的/var 空間快不夠,所以我想採取擴充其他目錄的方式分散網頁與文件資料,但現在不論本機端的磁碟陣列或NAS Server,網頁存取都會被拒絕。
我再研究看看,謝謝協助
froce iT邦大師 1 級 ‧ 2020-02-26 16:05:03 檢舉
chmod 『-R』...
去查一下加-R幹嘛用的,另外下面防火牆的應該不用試,被牆你要去防火牆的log找記錄不是找apache的紀錄。
jiannrong iT邦新手 5 級 ‧ 2020-02-26 16:11:29 檢舉
chmod與chown我都有做權限與使用者修改,也使用 httpd -t檢查設定,都沒有問題..
詭異的是我的磁碟陣列與Nas Server上的目錄於瀏覽器上都是一樣的錯誤,
目前看起來Alias設定沒有問題吧?
若Alias設定沒有問題,我想我得找一台機器產生最原始的httpd.conf檔案,
也許重新加入Alias設定就可以?
感謝各位的協助,我再試試看,若發現我哪一個細節我遺漏了,麻煩告訴我,感謝!
froce iT邦大師 1 級 ‧ 2020-02-26 16:23:56 檢舉
...去ls -al 那個檔案看權限吧,跳這個基本上都可以確定是權限設定問題。
如果懶得看-R是啥我直接說好了,-R就是連下層的檔案和資料夾都會吃設定(recursive)
-R, --recursive
operate on files and directories recursively

不加的話只有一層而已。

如果真的權限設對了,卻還是不行的話,你可能要檢查硬碟了...
jiannrong iT邦新手 5 級 ‧ 2020-02-26 16:59:33 檢舉
請問硬碟可能的原因是?
-R我知道會把下面所有項目都加入 -al 還可以看到隱藏檔案,沒有隱藏檔案,另外權限都是777 就是rwxrwxrwx
謝謝
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
casper2048
iT邦新手 4 級 ‧ 2020-02-26 14:32:20

You don't have permission to access /upload/2019/20192.pdf on this server.
Apache/2.2.15 (CentOS) Server at xxx.xxx.xxx.tw Port 80

看起來應該是防火牆擋掉
設一條規則允許PORT80

jiannrong iT邦新手 5 級 ‧ 2020-02-26 15:44:01 檢舉

我剛剛執行這一行

iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT

然後

[root@HP report]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-BadBots tcp -- anywhere anywhere multiport dports http,https
fail2ban-SSH tcp -- anywhere anywhere tcp dpt:5127
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:5127
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:mysql
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain fail2ban-BadBots (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

Chain fail2ban-SSH (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

httpd 重新啟動過,問題仍然相同。
我把fail2ban關閉,然猴重新啟動apache,依然是相同問題,請問不知是否還有哪裡需要做修改呢?
謝謝

selinux關掉看看,能想到的是這個問題

0

比較直覺的想法是檔案的所有人不同。
無法給web server權限取用。

可先做個測試,先將其檔案直接改成777權限看看是否就可以正常了。
如果分享目錄的帳號都是各自不同的情況下。那最好還是設個群組來分配權限會比較好點。

我要發表回答

立即登入回答