简体   繁体   English

/api/login_check 返回 404 未找到

[英]/api/login_check return 404 not found

I am trying to put my website on production.我正在尝试将我的网站投入生产。 For the authentification, I pass by the LexikJWTAuthenticationBundle.对于身份验证,我通过了 LexikJWTAuthenticationBundle。

I want to run my website on a Apache server.我想在 Apache 服务器上运行我的网站。 Passing by Apache when I run this command:运行此命令时经过 Apache:

curl -X POST -H "Content-Type: application/json" https://mywebsite.com/api/login_check -d '{"username":"admin","password":"admin"}' 

I get a 404 error.我收到 404 错误。

Meanwhile, If on the same machine I run symfony server:start and run this command:同时,如果在同一台机器上运行symfony server:start并运行此命令:

curl -X POST -H "Content-Type: application/json" https://127.0.0.1:8000/api/login_check -d '{"username":"admin","password":"admin"}'

I recieve the requested token.我收到请求的令牌。

if I make如果我让

bin/php debug:router bin/php 调试:路由器

api_login_check                                    POST     ANY      ANY    /api/login_check 

The VHost:虚拟主机:

<IfModule mod_ssl.c>
    <VirtualHost *:443>
    
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    RewriteEngine on
    ServerName exemple.com
    SSLCertificateFile /etc/.............
    SSLCertificateKeyFile /etc/...............
    Include /etc/..............
    
    <Directory /var/www/html/>
    Allowoverride all
    </Directory>
    #config backOffice intranet 
Alias /backend /var/www/html/backend/public/
    <Directory /var/www/html/backend/public/>
          SetEnv APP_ENV prod
          Require all granted
          AllowOverride all   
          Order Allow,Deny   
          Allow from All 
          Options -MultiViews
          RewriteEngine On
          RewriteBase /backend
          RewriteRule ^(.*)$ index.php [QSA,L]
    </Directory>
    
    </VirtualHost>
    </IfModule>

security:安全:

encoders:
    App\Entity\User:
        algorithm: bcrypt

providers:
    db_users:
        entity:
            class: App\Entity\User
            property: email
    jwt:
        lexik_jwt: ~

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    login:
        provider: db_users
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        json_login:
            username_path: username
            password_path: password
            check_path: /api/login_check
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
            require_previous_session: false
    api:
        pattern: ^/api
        provider: jwt
        stateless: true
        anonymous: true
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator
    main:
        anonymous: true

# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
    - { path: ^/api/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/health, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/user/inscription, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/user/test, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/user/password/edit, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

role_hierarchy:
    ROLE_USER: ROLE_USER
    ROLE_ADMIN: ROLE_ADMIN

I am bit lost, tell me if you need more info.我有点迷路,如果您需要更多信息,请告诉我。 Thanks谢谢

<IfModule mod_ssl.c>
    <VirtualHost *:443>
    
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/backend/public
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    RewriteEngine on
    ServerName exemple.com
    SSLCertificateFile /etc/.............
    SSLCertificateKeyFile /etc/...............
    Include /etc/..............
    
    <Directory /var/www/html/>
    Allowoverride all
    </Directory>
    #config backOffice intranet 
Alias /backend /var/www/html/backend/public/
    <Directory /var/www/html/backend/public/>
          SetEnv APP_ENV prod
          Require all granted
          AllowOverride all   
          Order Allow,Deny   
          Allow from All 
          Options -MultiViews
          RewriteEngine On
          RewriteBase /backend
          RewriteRule ^(.*)$ index.php [QSA,L]
    </Directory>
    
    </VirtualHost>
    </IfModule>
  • composer require symfony/apache-pack作曲家需要 symfony/apache-pack

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM