【问题标题】:Is there a way to specify hostname in laravel octane有没有办法在 laravel octane 中指定主机名
【发布时间】:2021-09-02 12:12:46
【问题描述】:

当我启动 octane 时,它​​总是使用这个主机 http ://127.0.0.1:8000 ,这可用于本地开发,但在生产环境中我使用域名而不是 localhost 当我们启动 octane 时,有没有办法像 http ://domain.com:8000 这样更改主机名。

更新: 我正在使用阿帕奇

更新: 我切换到 Nginx 所以,它比 apache 工作得更好。但是,如果有人设法在 Apache 中解决了这个问题,欢迎离开您的配置。

【问题讨论】:

    标签: laravel octane


    【解决方案1】:

    您需要 Nginx 或 Apache。它已经在Octane Documentation 上。

    在下面的 Nginx 配置示例文件中,Nginx 会将站点的静态资产和代理请求提供给在端口 8000 上运行的 Octane 服务器:

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }
    
    server {
        listen 80; // or 8000
        listen [::]:80; // or 8000
        server_name domain.com;
        server_tokens off;
        root /your/octane_path/public;
    
        index index.php;
    
        charset utf-8;
    
        location /index.php {
            try_files /not_exists @octane;
        }
    
        location / {
            try_files $uri $uri/ @octane;
        }
    
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
    
        access_log off;
        error_log  /var/log/nginx/domain.com-error.log error;
    
        error_page 404 /index.php;
    
        location @octane {
            set $suffix "";
    
            if ($uri = /index.php) {
                set $suffix ?$query_string;
            }
    
            proxy_http_version 1.1;
            proxy_set_header Host $http_host;
            proxy_set_header Scheme $scheme;
            proxy_set_header SERVER_PORT $server_port;
            proxy_set_header REMOTE_ADDR $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
    
            proxy_pass http://127.0.0.1:8000$suffix;
        }
    }
    

    【讨论】:

    • 感谢您的回复。我知道,但我使用的是 apache,我不能使用我自己的域,甚至不能使用 https 而不是 http(OCTANE_HTTPS 设置为 true)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-10
    • 2023-01-19
    • 1970-01-01
    • 2010-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多