laravel - 启动 laravel swagger 时重定向到正确的 docker 主机的问题
问题描述
我在 Laravel 5.5 和带有 nginx 配置的 docker 上安装和使用我的 Laravel-swagger 包时遇到问题。问题是,当我尝试使用已安装的 swagger (如https://127.0.0.1:8080/api/documentation /127.0.0.1/docs/asset/swagger-ui.css?v=1f524b0bbfd05a62b996252847139c9d 在此处输入图像描述
我试图通过更改我的 docker 和 nginx 配置文件的配置来解决这个问题。以下是一些例子:
docker-compose.yaml
nginx:
container_name: ${SERVICE_NAME}-nginx
build:
context: ./docker/nginx/
dockerfile: Dockerfile
args:
USER_ID: $USER_ID
GROUP_ID: $GROUP_ID
ports:
- "$CONTAINER_PORT_NGINX:8080"
depends_on:
- php
environment:
TZ: 'Europe/Moscow'
networks:
- default
# read_only: true
tmpfs:
- /var/cache/nginx
- /var/lib/nginx
- /var/lib/nginx/logs/
- /var/tmp/nginx/proxy
- /var/tmp/nginx/fastcgi
- /var/tmp/nginx/client_body
- /var/tmp/nginx/uwsgi
- /var/tmp/nginx/scgi
- /run
- /tmp
restart: unless-stopped
stdin_open: true
tty: true
volumes:
- .:/var/www/html:cached
Dockerfile
FROM alpine:3.10
ARG USER_ID
ARG GROUP_ID
RUN apk --update --no-cache add nginx shadow
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/conf.d/default.conf
RUN groupmod -g ${GROUP_ID} www-data && adduser -D -g '' -u ${USER_ID} -G www-data www-data
CMD ["nginx"]
EXPOSE 8080
默认.conf
upstream php-upstream {
server php:9000;
}
server {
listen 8080;
server_name localhost;
root /var/www/html/public;
index index.php index.html index.htm;
charset utf-8;
location / {
absolute_redirect on;
try_files $uri $uri/ /index.php?$query_string;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|txt|mp3|js|html)$
{
expires 7d;
access_log off;
add_header Cache-Control "public";
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_read_timeout 600;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_pass php-upstream;
fastcgi_param HTTP_HOST $host;
}
error_log /var/log/nginx/site_error.log;
access_log /var/log/nginx/site_access.log;
# ---REM--- send_timeout 300;
# Disable logging for favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Disable logging for robots.txt
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* /\. {
deny all;
}
}
但没有什么能帮到我,我在 docker 和配置 nginx 应用程序方面不是那么强,所以我真的需要帮助来解决这个问题。谢谢
解决方案
推荐阅读
- ios - 运行录制 AVAudioSession 时取消静音通知声音/振动
- javascript - 字符串到 DOM 的转换
- c# - WPF - 覆盖子/内部控件上的继承样式
- awk - grep, awk - 每隔第一行输出一次
- wordpress - 请建议具有良好动画效果和外观的画廊插件名称也不错?
- java - Java - 分布式对象逻辑:服务器作为存储/客户端作为工作者
- javascript - Internet Explorer 11 中的“未处理的承诺拒绝 TypeMismatchError”
- javascript - 添加自定义元素作为另一个自定义元素的子元素
- spring - 使用 STOMP 简单代理时的错误处理
- python - 在两个熊猫数据帧之间搜索忽略时间的最快和最正确的方法