最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Symfony or Nginx is forcing a redirect to https in a Docker test environment - Stack Overflow

programmeradmin7浏览0评论

please help. I'm having a problem with a droplet in DigitalOcean with a Symfony app. The app portal works fine, but when I log in to a module with security (username and password), the styles and JS aren't loaded, and all links are redirected to https. This doesn't happen on my local dev machine, and the links are displayed as http.

I have two containers: the first with a Symfony 6 app and the second with Nginx for reverse proxy. In DigitalOcean, I set up the $15 Managed PostgreSQL, which has SSL certificates. Could this be forcing the modules to work with an https login?

I set up another droplet to start from scratch and installed PostgreSQL on the droplet, but the problem still persists. I don't know if Symfony or Nginx are forcing the links to be redirected to https. I'm logging in via IP, but I haven't configured the domain yet.

All this is for a test server

# This script is for the nginx dockerfile
server {
    listen 80;
    index index.php;
    server_name localhost;
    root /appdata/www/public;
    client_max_body_size 10M;

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\\.php(/|$) {
        fastcgi_pass app:3020;
        fastcgi_split_path_info ^(.+\\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }

    location ~ \\.php$ {
        return 404;
    }
}

services:

  app:
    image: superarchihub:superarchi:latest
    container_name: superarchi-app
    networks:
      - superarchi-network
    volumes:
      - service-data:/appdata/www/public
      - ./media:/appdata/www/public/media
      - ./var:/appdata/www/var/log

  web:
    image: superarchihub:ngynxsuperarchi:latest
    container_name: superarchi-web
    ports:
      - '8030:80'
    volumes:
      - service-data:/appdata/www/public
      - ./media:/appdata/www/public/media
    links:
      - app
    networks:
      - superarchi-network
    depends_on:
      - app

  mailer:
    container_name: superarchi-mailer
    image: axllent/mailpit
    ports:
      - "1040:1025"
      - "8040:8025"
    environment:
      MP_SMTP_AUTH_ACCEPT_ANY: 1
      MP_SMTP_AUTH_ALLOW_INSECURE: 1
    networks:
      - superarchi-network

networks:
  superarchi-network:
    external: true

volumes:
  service-data:
    external: true

Any ideas, thanks in advance

please help. I'm having a problem with a droplet in DigitalOcean with a Symfony app. The app portal works fine, but when I log in to a module with security (username and password), the styles and JS aren't loaded, and all links are redirected to https. This doesn't happen on my local dev machine, and the links are displayed as http.

I have two containers: the first with a Symfony 6 app and the second with Nginx for reverse proxy. In DigitalOcean, I set up the $15 Managed PostgreSQL, which has SSL certificates. Could this be forcing the modules to work with an https login?

I set up another droplet to start from scratch and installed PostgreSQL on the droplet, but the problem still persists. I don't know if Symfony or Nginx are forcing the links to be redirected to https. I'm logging in via IP, but I haven't configured the domain yet.

All this is for a test server

# This script is for the nginx dockerfile
server {
    listen 80;
    index index.php;
    server_name localhost;
    root /appdata/www/public;
    client_max_body_size 10M;

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\\.php(/|$) {
        fastcgi_pass app:3020;
        fastcgi_split_path_info ^(.+\\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }

    location ~ \\.php$ {
        return 404;
    }
}

services:

  app:
    image: superarchihub:superarchi:latest
    container_name: superarchi-app
    networks:
      - superarchi-network
    volumes:
      - service-data:/appdata/www/public
      - ./media:/appdata/www/public/media
      - ./var:/appdata/www/var/log

  web:
    image: superarchihub:ngynxsuperarchi:latest
    container_name: superarchi-web
    ports:
      - '8030:80'
    volumes:
      - service-data:/appdata/www/public
      - ./media:/appdata/www/public/media
    links:
      - app
    networks:
      - superarchi-network
    depends_on:
      - app

  mailer:
    container_name: superarchi-mailer
    image: axllent/mailpit
    ports:
      - "1040:1025"
      - "8040:8025"
    environment:
      MP_SMTP_AUTH_ACCEPT_ANY: 1
      MP_SMTP_AUTH_ALLOW_INSECURE: 1
    networks:
      - superarchi-network

networks:
  superarchi-network:
    external: true

volumes:
  service-data:
    external: true

Any ideas, thanks in advance

Share Improve this question asked Mar 27 at 2:16 mario uriartemario uriarte 295 bronze badges 1
  • 1 Look in the networks tab of the developer console in your browser to find a call that gets redirected. It should be getting a 302 response code. Then investigate that single call by looking at container logs. You can repeat that single call using curl or Postman. Hopefully that'll tell you where the call gets redirected. – Hans Kilian Commented Mar 27 at 6:30
Add a comment  | 

1 Answer 1

Reset to default 0

The problem was solved, after so much debugging the problem was an HTML tag <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> , nothing to do with symfony or nginx

发布评论

评论列表(0)

  1. 暂无评论