You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/06 08:27:06 UTC
[GitHub] [apisix] CGerAJ opened a new issue #4544: request help: How to configure a single-page application in APISIX?
CGerAJ opened a new issue #4544:
URL: https://github.com/apache/apisix/issues/4544
### Issue description
I want to deploy a reactjs single page application, How to configure a single-page application in APISIX?
some docs
```
https://apisix.apache.org/zh/docs/apisix/customize-nginx-configuration
```
### Environment
Request help without environment information will be ignored or closed.
* apisix version (cmd: `apisix version`): 2.5
* OS (cmd: `uname -a`): Linux i-12on6zcy 4.18.0-240.el8.x86_64 #1 SMP Fri Sep 25 19:48:47 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): nginx version: openresty/1.19.3.1
* etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
* apisix-dashboard version, if have: 2.6
* luarocks version, if the issue is about installation (cmd: `luarocks --version`):
/usr/local/bin/luarocks 3.4.0
LuaRocks main command-line interface
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] CGerAJ edited a comment on issue #4544: request help: How to configure a single-page application(SPA) in APISIX?
Posted by GitBox <gi...@apache.org>.
CGerAJ edited a comment on issue #4544:
URL: https://github.com/apache/apisix/issues/4544#issuecomment-875422045
Thanks for the answer @membphis @Yiyiyimu
Train of thought
```
client -> apisix(80) -> 127.0.0.1:8000(local nginx)
```
this is my config
step1: You should modify config.yaml
```
nginx_config:
main_configuration_snippet: |
daemon on;
http_configuration_snippet: |
server {
listen 8099;
server_name localhost;
charset utf-8;
location / {
# Your SPA build file like this
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
expires -1s;
}
}
chunked_transfer_encoding on;
http_server_configuration_snippet: |
set $my "var";
http_admin_configuration_snippet: |
log_format admin "$request_time $pipe";
http_end_configuration_snippet: |
server_names_hash_bucket_size 128;
stream_configuration_snippet: |
tcp_nodelay off;
```
step2: config you apisix route, Here’s a reference configuration.
```
{"code":0,"message":"","data":{"id":"362576314554647276","create_time":1625641924,"update_time":1625643730,"uris":["/*"],"name":"vue3","desc":"SPA","priority":1,"methods":["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS","CONNECT","TRACE"],"hosts":["you host address"],"upstream":{"nodes":[{"host":"127.0.0.1","port":8099,"weight":1}],"retries":2,"timeout":{"connect":6,"read":6,"send":6},"type":"roundrobin","scheme":"http","pass_host":"pass"},"status":1},"request_id":"927ec2b0-559f-4465-bfcb-38edb2384786"}
```
Points to note:
- YAML file format
YAML file format can not be wrong, you can test your configuration through `apisix reload`
- Permission denied
I am not particularly familiar with this area and need to check the directory file permissions level by Level.
Official QQ552030619 exchange group solved my problem, thank you very much
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] CGerAJ closed issue #4544: request help: How to configure a single-page application(SPA) in APISIX?
Posted by GitBox <gi...@apache.org>.
CGerAJ closed issue #4544:
URL: https://github.com/apache/apisix/issues/4544
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Yiyiyimu commented on issue #4544: request help: How to configure a single-page application in APISIX?
Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on issue #4544:
URL: https://github.com/apache/apisix/issues/4544#issuecomment-874958995
I guess using url of that application of APISIX upstream is enough
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] CGerAJ commented on issue #4544: request help: How to configure a single-page application in APISIX?
Posted by GitBox <gi...@apache.org>.
CGerAJ commented on issue #4544:
URL: https://github.com/apache/apisix/issues/4544#issuecomment-875316440
# SPA application nginx config
```
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ @router;
index index.html;
expires -1;
}
location @router {
rewrite ^.*$ /index.html break;
}
}
```
When you visit a SPA single page, you are actually accessing a single page route, such as/goods/list, which corresponds to the routing component configured in a single page route. But for Nginx servers, it is thought that they will look for the list folder under the goods folder in the root directory, **A single page actually has only one page, index. HTML, so need to rewirte all the pages to the index page**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] CGerAJ commented on issue #4544: request help: How to configure a single-page application(SPA) in APISIX?
Posted by GitBox <gi...@apache.org>.
CGerAJ commented on issue #4544:
URL: https://github.com/apache/apisix/issues/4544#issuecomment-875422045
Thanks for the answer @membphis @Yiyiyimu
Train of thought
```
client -> apisix(80) -> 127.0.0.1:8000(local nginx)
```
this is my config
step1: You should modify config.yaml
```
nginx_config:
main_configuration_snippet: |
daemon on;
http_configuration_snippet: |
server {
listen 8099;
server_name localhost;
charset utf-8;
location / {
# Your SPA build file like this
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
expires -1s;
}
}
chunked_transfer_encoding on;
http_server_configuration_snippet: |
set $my "var";
http_admin_configuration_snippet: |
log_format admin "$request_time $pipe";
http_end_configuration_snippet: |
server_names_hash_bucket_size 128;
stream_configuration_snippet: |
tcp_nodelay off;
```
step2: config you apisix route, Here’s a reference configuration.
```
{"code":0,"message":"","data":{"id":"362576314554647276","create_time":1625641924,"update_time":1625643730,"uris":["/*"],"name":"vue3","desc":"SPA","priority":1,"methods":["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS","CONNECT","TRACE"],"hosts":["you host address"],"upstream":{"nodes":[{"host":"127.0.0.1","port":8099,"weight":1}],"retries":2,"timeout":{"connect":6,"read":6,"send":6},"type":"roundrobin","scheme":"http","pass_host":"pass"},"status":1},"request_id":"927ec2b0-559f-4465-bfcb-38edb2384786"}
```
Points to note:
- YAML file format
YAML file format can not be wrong, you can test your configuration through apisix reload
- Permission denied
I am not particularly familiar with this area and need to check the directory file permissions level by Level.
Official QQ552030619 exchange group solved my problem, thank you very much
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] CGerAJ commented on issue #4544: request help: How to configure a single-page application in APISIX?
Posted by GitBox <gi...@apache.org>.
CGerAJ commented on issue #4544:
URL: https://github.com/apache/apisix/issues/4544#issuecomment-875198689
I’m trying customize-nginx-configuration
> I guess using url of that application of APISIX upstream is enough
>
> 我想使用 APISIX 上游应用程序的 url 就足够了
Can you help provide some documentation?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org