I'm trying to get access to the layer of Geoserver using the following code in javascript
var gkvrtWmsSource =new ol.source.ImageWMS({
url:'http://geoserver-host-ip/geoserver/ukrforest/wms',
params: {'LAYERS':'kvartal_polygon'},
serverType:'geoserver',
crossOrigin: 'anonymous',
});
var gkvrtWmsLayer=new ol.layer.Image({
source:gkvrtWmsSource
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
gkvrtWmsLayer,
],
target: 'map1',
view: new ol.View({
center: ol.proj.transform([31, 50], 'EPSG:4326', 'EPSG:3857'),
zoom: 10
}),
});
The Geoserver was configured on Ubuntu 16.04 and Apache 2.4.18 (Tomcat7) According to the post https://stackoverflow.com/questions/25490051/access-geoserver-from-internet-ubuntu-server-14-04-1 added the following instructions to the file etc/apache2/sites-available/000-default.conf
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /geoserver "http://localhost:8080/geoserver"
ProxyPassReverse /geoserver "http://localhost:8080/geoserver"
Then enabled 4 modules to use Apache as a Reverse Proxy with mod_proxy on Ubuntu 16.04
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
Restarted Apache
Still, on client-side have the following message
wms:1 GET http://geoserver-host-ip/geoserver/ukrforest/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=kvartal_polygon&CRS=EPSG%3A3857&STYLES=&WIDTH=444&HEIGHT=881&BBOX=3245143.983882646%2C6312336.14137978%2C3516648.308351592%2C6851064.316733702 403 (Forbidden)
What have I done done wrong?
Actually I managed to get access to Geoserver layers after reinstalling Geoserver. So if somebody is going to use Geoserver for publishing map layers with Openlayers the details of my question may be taken into consideration. Especially if the problem with cross-origin resource sharing (CORS) will appear.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.