Скрипт Rust «hello world» не запускается через ajax-вызовы, а выполняется через curl на самом сервере.Apache

Ответить
Anonymous
 Скрипт Rust «hello world» не запускается через ajax-вызовы, а выполняется через curl на самом сервере.

Сообщение Anonymous »

У меня есть веб-приложение PHP, использующее Apache. Я пытаюсь добавить возможность запуска скриптов Rust.
Я могу заставить его работать на локальном хосте через:

Код: Выделить всё

fetch('/rust/hello')  // Proxy through Apache (no need for port in URL)
.then(response => response.text())
.then(data => {
console.log(data);  // Should log "Hello, world!"
})
.catch(error => console.error('Error:', error));
Он также работает в рабочей среде с помощью команды CLI: curl http://localhost:8080/hello
Я не могу получить AJAX вызов для работы над производством.
Я думаю, что ошибка может быть связана с пользовательской маршрутизацией, которую я настроил в .htaccess (в корневом каталоге моего приложения). и/или 000-default-le-ssl.conf в каталоге конфигурации Apache.
Мой .htaccess:

Код: Выделить всё

Require all denied


RewriteEngine On

# Exclude /rust path from being rewritten
RewriteCond %{REQUEST_URI} ^/rust
RewriteRule ^rust/(.*)$ http://localhost:8080/$1 [P,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Мой 000-default-le-ssl.conf:

Код: Выделить всё

ServerName mywebsite.net
ServerAlias www.mywebsite.net

RewriteEngine on

# Skip redirection for /rust path
# RewriteCond %{REQUEST_URI} !^/rust

# Redirect everything else to HTTPS
RewriteCond %{SERVER_NAME} =mywebsite.net [OR]
RewriteCond %{SERVER_NAME} =www.mywebsite.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

# Proxy configuration
ProxyRequests Off
ProxyPreserveHost On

# ProxyPass for /rust/*
#    RewriteCond %{REQUEST_URI} !^/rust
#    ProxyPass /rust http://localhost:8080/
#    ProxyPassReverse /rust http://localhost:8080/

#    ProxyPass /rust/hello http://localhost:8080/hello
#    ProxyPassReverse /rust/hello http://localhost:8080/hello

DocumentRoot /var/www/html

Options -Indexes
AllowOverride All
Require all granted


# Prevent access to .env files

Require all denied


ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined



ServerName mywebsite.net
ServerAlias www.mywebsite.net

DocumentRoot /var/www/html

Options -Indexes
AllowOverride All
Require all granted


# SSL Configuration
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.mywebsite.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.mywebsite.net/privkey.pem

# Redirect from HTTP to HTTPS
RewriteEngine on
RewriteCond %{HTTP_HOST} =mywebsite.net [OR]
RewriteCond %{HTTP_HOST} =www.mywebsite.net
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [END,NE,R=permanent]

# Prevent access to .env files

Require all denied


ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Я перепробовал много вариантов разрешений и маршрутизации, но не могу понять, что делаю не так.

Подробнее здесь: https://stackoverflow.com/questions/791 ... in-the-ser
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Apache»