我有一个名称为service1.mydomain.local(apache + php)的本地服务,一切都按照内部网络的设计工作。我需要有相同的服务从外面通过名称service1.mydomain.com
我也有nginx代理作为网络中的主要http服务器。很多资源通过它工作得很好。
最好的配置,我有这个特殊的情况下不显示css和图片。请帮助修复css和图片。
Nginx
`server {
listen 80;
server_name service1.mydomain.com;
include snippets/letsencrypt.conf;
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl http2;
server_name service1.mydomain.com;
include snippets/letsencrypt.conf;
ssl_certificate /etc/letsencrypt/live/service1.mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/service1.mydomain.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/service1.mydomain.com/chain.pem;
access_log /var/log/nginx/service1.access.log;
error_log /var/log/nginx/service1.error.log info;
location / {
try_files $uri $uri/ /index.php?/$request_uri; #/index.php$args;
}
location ~ \.php$ {
proxy_pass http://service1.mydomain.local:80;
proxy_set_header Host service1.mydomain.local; #$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;
}
location ~ /\. {
deny all;
}
}`
字符串
Apache
`<VirtualHost *:80>
ServerName service1.mydomain.local
DocumentRoot /usr/share/self-service-password/htdocs
DirectoryIndex index.php
AddDefaultCharset UTF-8
<Directory /usr/share/self-service-password/htdocs>
AllowOverride None
<IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfVersion < 2.3>
Order Deny,Allow
Allow from all
</IfVersion>
</Directory>
Alias /rest /usr/share/self-service-password/rest
<Directory /usr/share/self-service-password/rest>
AllowOverride None
<IfVersion >= 2.3>
Require all denied
</IfVersion>
<IfVersion < 2.3>
Order Deny,Allow
Deny from all
</IfVersion>
</Directory>
LogLevel warn
ErrorLog /var/log/apache2/ssp_error.log
CustomLog /var/log/apache2/ssp_access.log combined
</VirtualHost>`
型
internal network answer - correctexternal network answer - incorrect
1条答案
按热度按时间e7arh2l61#
在你的nginx配置中,以下部分可能是一个问题:
字符串
这基本上意味着,你只代理以php结尾的请求,并拒绝所有其他请求。
可以尝试将
location ~ \.php$ {
更改为location ~* \.(png|ico|gif|jpg|jpeg|css|js|php)$ {
。这些结尾只是一个例子,你可以允许你想要的。